-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathaccount-status.jsx
More file actions
141 lines (132 loc) · 4.66 KB
/
account-status.jsx
File metadata and controls
141 lines (132 loc) · 4.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
import React from 'react';
import PropTypes from 'prop-types';
import ContentBox from 'components/core/content-box';
import { SliderCheckbox } from 'components/core/checkbox';
import { connect } from 'react-redux';
import * as CustomersActions from '../../modules/customers/details';
import ConfirmationModal from 'components/core/confirmation-modal';
@connect((state, props) => ({
...state.customers.details
}), CustomersActions)
export default class CustomerAccountStatus extends React.Component {
static propTypes = {
customer: PropTypes.object.isRequired,
toggleDisableStatus: PropTypes.func.isRequired,
startDisablingCustomer: PropTypes.func.isRequired,
stopDisablingCustomer: PropTypes.func.isRequired,
toggleBlacklisted: PropTypes.func.isRequired,
startBlacklistCustomer: PropTypes.func.isRequired,
stopBlacklistCustomer: PropTypes.func.isRequired,
isDisablingStarted: PropTypes.bool.isRequired,
isBlacklistedStarted: PropTypes.bool.isRequired
};
get customerInfo() {
const customer = this.props.customer;
return (
<ul className="fc-customer-disable-confirm-customer">
<li><strong>{customer.name}</strong></li>
<li>{customer.email}</li>
<li>{customer.phoneNumber}</li>
</ul>
);
}
get disableOptions() {
const customer = this.props.customer;
if (customer.disabled) {
return {
title: 'Activate Customer Account',
children: (
<div className="fc-customer-disable-confirm">
<div>Are you sure you want to active the account for the following customer?</div>
{this.customerInfo}
<div>You can deactivate this account at anytime.</div>
</div>
),
confirmLabel: 'Yes, Activate Account',
};
} else {
return {
title: 'Deactivate Customer Account',
children: (
<div className="fc-customer-disable-confirm">
<div>Are you sure you want to deactivate the account for the following customer?</div>
{this.customerInfo}
<div>You can reactivate this account at anytime.</div>
</div>
),
confirmLabel: 'Yes, Deactivate Account',
};
}
}
get blacklistedOptions() {
const customer = this.props.customer;
if (customer.isBlacklisted) {
return {
title: 'Remove Customer From Blacklist',
body: (
<div className="fc-customer-blacklist-confirm">
<div>Are you sure you want to remove the following customer from the Blacklist?</div>
{this.customerInfo}
<div>You can place this customer on the Blacklist at anytime.</div>
</div>
),
confirmLabel: 'Yes, Remove',
};
} else {
return {
title: 'Blacklist Customer',
body: (
<div className="fc-customer-blacklist-confirm">
<div>Are you sure you want to place the following custom on the Blacklist?</div>
{this.customerInfo}
<div>You can take this customer off the Blacklist at anytime.</div>
</div>
),
confirmLabel: 'Yes, Blacklist',
};
}
}
render() {
let customer = this.props.customer;
return (
<div>
<ContentBox title="Account Status" className="fc-customer-account-status">
<div className="fc-customer-status-row">
<strong>Active Account</strong>
<SliderCheckbox
id="customerDisabled"
onChange={this.props.startDisablingCustomer}
checked={ !customer.disabled }
/>
</div>
<div className="fc-customer-status-row">
<strong>Blacklist Customer</strong>
<SliderCheckbox
id="customerBlacklisted"
onChange={this.props.startBlacklistCustomer}
checked={ customer.isBlacklisted }
/>
</div>
<ConfirmationModal
{...this.disableOptions}
isVisible={this.props.isDisablingStarted}
onConfirm={() => {
const customer = this.props.customer;
this.props.toggleDisableStatus(customer.id, !customer.disabled);
}}
onCancel={this.props.stopDisablingCustomer}
/>
<ConfirmationModal
{...this.blacklistedOptions}
isVisible={this.props.isBlacklistedStarted}
onConfirm={() => {
const customer = this.props.customer;
this.props.toggleBlacklisted(customer.id, !customer.isBlacklisted);
}}
onCancel={this.props.stopBlacklistCustomer}
/>
</ContentBox>
</div>
);
}
}