forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsx
More file actions
151 lines (140 loc) · 4.28 KB
/
index.jsx
File metadata and controls
151 lines (140 loc) · 4.28 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
142
143
144
145
146
147
148
149
150
151
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import { useIntl, FormattedMessage } from '@edx/frontend-platform/i18n';
import {
PageBanner, Button, Card, MailtoLink, Hyperlink,
} from '@openedx/paragon';
import { Email as EmailIcon } from '@openedx/paragon/icons';
import SectionSubHeader from '../../generic/section-sub-header';
import { INVITE_STUDENTS_LINK_ID } from './constants';
import messages from './messages';
const BasicSection = ({
org,
courseNumber,
run,
lmsLinkForAboutPage,
marketingEnabled,
courseDisplayName,
platformName,
}) => {
const intl = useIntl();
const [showPageBanner, setShowPageBanner] = useState(true);
const emailSubject = intl.formatMessage(
{
id: 'course-authoring.schedule.basic.email.subject',
defaultMessage: 'Enroll in {courseDisplayName}.',
},
{ courseDisplayName },
);
const emailBody = intl.formatMessage(
{
id: 'course-authoring.schedule.basic.email.body',
defaultMessage:
'The course {courseDisplayName}, provided by {platformName}, is open for enrollment. Please navigate to this course at {lmsLinkForAboutPage} to enroll.',
},
{
courseDisplayName,
platformName,
lmsLinkForAboutPage,
},
);
const promotionTitle = (
<FormattedMessage
id="course-authoring.schedule.basic.promotion.title"
defaultMessage="Course summary page {smallText}"
values={{
smallText: <small>(for student enrollment and access)</small>,
}}
/>
);
const courseBasicInfo = [
{
label: `${intl.formatMessage(messages.courseOrganization)}`,
prefix: 'basic-organization',
value: org,
},
{
label: `${intl.formatMessage(messages.courseNumber)}`,
prefix: 'basic-course-number',
value: courseNumber,
},
{
label: `${intl.formatMessage(messages.courseRun)}`,
prefix: 'basic-course-run',
value: run,
},
];
const renderBasicInfo = (info) => (
<li key={info.prefix}>
<h4 className="mb-0 text-black">{info.label}</h4>
<span className="small text-black">{info.value}</span>
</li>
);
const renderPageBanner = () => (
<PageBanner
show={showPageBanner}
dismissible
onDismiss={() => setShowPageBanner(false)}
className="align-items-start"
>
<h4 className="text-black">{intl.formatMessage(messages.basicBannerTitle, { platformName })}</h4>
<span className="text text-gray-700 text-left">
{intl.formatMessage(messages.basicBannerText)}
</span>
</PageBanner>
);
const renderCoursePromotion = () => (
<Card>
<Card.Header
className="h4 px-3 text-gray-500"
title={promotionTitle}
size="sm"
/>
<Card.Section className="px-3 py-1">
<Hyperlink
destination={lmsLinkForAboutPage}
className="lead info-500 small text-decoration-none"
target="_blank"
showLaunchIcon={false}
>
{lmsLinkForAboutPage}
</Hyperlink>
</Card.Section>
<Card.Divider />
<Card.Footer className="p-3 justify-content-start">
<MailtoLink
to={process.env.INVITE_STUDENTS_EMAIL_TO}
subject={emailSubject}
body={emailBody}
data-testid={INVITE_STUDENTS_LINK_ID}
>
<Button variant="outline-primary" iconBefore={EmailIcon} size="sm">
{intl.formatMessage(messages.basicPromotionButton)}
</Button>
</MailtoLink>
</Card.Footer>
</Card>
);
return (
<section className="section-container basic-section">
<SectionSubHeader
title={intl.formatMessage(messages.basicTitle)}
description={intl.formatMessage(messages.basicDescription)}
/>
<ul className="basic-info-list">
{courseBasicInfo.map(renderBasicInfo)}
</ul>
{marketingEnabled ? renderPageBanner() : renderCoursePromotion()}
</section>
);
};
BasicSection.propTypes = {
org: PropTypes.string.isRequired,
courseNumber: PropTypes.string.isRequired,
run: PropTypes.string.isRequired,
lmsLinkForAboutPage: PropTypes.string.isRequired,
marketingEnabled: PropTypes.bool.isRequired,
courseDisplayName: PropTypes.string.isRequired,
platformName: PropTypes.string.isRequired,
};
export default BasicSection;