-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathCustomerCard.jsx
97 lines (92 loc) · 2.99 KB
/
CustomerCard.jsx
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
import PropTypes from 'prop-types';
import {
ActionRow, Button, Card, Icon, Hyperlink, Toast, useToggle,
} from '@openedx/paragon';
import { Launch, ContentCopy } from '@openedx/paragon/icons';
import { getConfig } from '@edx/frontend-platform';
import { formatDate, useCopyToClipboard } from '../data/utils';
import CustomerDetailModal from './CustomerDetailModal';
const CustomerCard = ({ enterpriseCustomer }) => {
const { ADMIN_PORTAL_BASE_URL, DJANGO_ADMIN_LMS_BASE_URL } = getConfig();
const { showToast, copyToClipboard, setShowToast } = useCopyToClipboard(enterpriseCustomer.uuid);
const [isDetailsOpen, openDetails, closeDetails] = useToggle(false);
return (
<div>
<CustomerDetailModal
customer={enterpriseCustomer}
isOpen={isDetailsOpen}
close={closeDetails}
/>
<Card variant="dark" className="mb-0">
<Card.Section
actions={(
<ActionRow>
<Button onClick={openDetails}>View Details</Button>
<Button
className="text-dark-500"
as="a"
href={`${DJANGO_ADMIN_LMS_BASE_URL}/admin/enterprise/enterprisecustomer/${enterpriseCustomer.uuid}/change`}
variant="inverse-primary"
target="_blank"
rel="noopener noreferrer"
iconAfter={Launch}
>
Open in Django
</Button>
</ActionRow>
)}
>
<p className="small font-weight-bold mb-0 mt-2">
CUSTOMER RECORD
</p>
<p className="lead font-weight-bold mb-0">
{enterpriseCustomer.name}
</p>
<Hyperlink
destination={`${ADMIN_PORTAL_BASE_URL}/${enterpriseCustomer.slug}/admin/learners`}
variant="muted"
target="_blank"
showLaunchIcon
className="small mb-1"
>
/{enterpriseCustomer.slug}/
</Hyperlink>
<div
role="presentation"
className="pgn-doc__icons-table__preview-footer"
>
<p className="small mb-1">
{enterpriseCustomer.uuid}
</p>
<Icon
key="ContentCopy"
src={ContentCopy}
data-testid="copy"
onClick={() => copyToClipboard()}
/>
</div>
<p className="small mb-1">
Created {formatDate(enterpriseCustomer.created)} • Last modified {formatDate(enterpriseCustomer.modified)}
</p>
</Card.Section>
</Card>
<Toast
onClose={() => setShowToast(false)}
show={showToast}
delay={2000}
>
Copied to clipboard
</Toast>
</div>
);
};
CustomerCard.propTypes = {
enterpriseCustomer: PropTypes.shape({
created: PropTypes.string,
modified: PropTypes.string,
slug: PropTypes.string,
name: PropTypes.string,
uuid: PropTypes.string,
}).isRequired,
};
export default CustomerCard;