-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEnrol.tsx
More file actions
98 lines (92 loc) · 3.02 KB
/
Copy pathEnrol.tsx
File metadata and controls
98 lines (92 loc) · 3.02 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
import { useTranslation } from 'react-i18next';
import joinClassNames from 'classnames';
import styles from './enrol.module.scss';
import OccurrenceInfo from '../partial/OccurrenceInfo';
import Button from '../../../common/components/button/Button';
import EventOccurrenceNotificationControlButton from '../EventOccurrenceNotificationControlButton';
import { OccurrenceFields } from '../types/OccurrenceQueryTypes';
import AppConfig from '../../app/AppConfig';
import Paragraph from '../../../common/components/paragraph/Paragraph';
type Props = {
childId: string;
occurrence: OccurrenceFields;
onCancel: () => void;
onEnrol: () => void;
onUnsubscribed?: () => void;
onSubscribe?: () => void;
onSubscribed?: () => void;
};
const Enrol = ({
childId,
occurrence,
onCancel,
onEnrol,
onUnsubscribed,
onSubscribe,
onSubscribed,
}: Props) => {
const { t } = useTranslation();
const isFull = occurrence.remainingCapacity === 0;
const isChildHasActiveSubscription = Boolean(
occurrence.childHasFreeSpotNotificationSubscription
);
const eventName = occurrence.event.name;
return (
<>
<div className={styles.enrolWrapper} role="main">
<div className={styles.heading}>
<h1>
{!isFull &&
`${t('enrollment.confirmationPage.heading.text')} ${eventName}`}
{isFull &&
t('enrollment.confirmationPage.heading.full', { eventName })}
</h1>
</div>
<div className={styles.text}>
<Paragraph
text={
!isFull
? t('enrollment.confirmationPage.description.text', {
unerolHoursBeforeOccurrence:
AppConfig.enrolmentCancellationTimeLimitHours,
})
: t('enrollment.confirmationPage.description.full')
}
/>
</div>
<OccurrenceInfo
occurrence={occurrence}
className={joinClassNames(styles.occurrenceInfo, styles.wrap)}
/>
<div className={styles.actions}>
{!isFull && (
<Button onClick={onEnrol}>
{t('enrollment.confirmationPage.confirm.button')}
</Button>
)}
{isFull && (
<EventOccurrenceNotificationControlButton
childId={childId}
eventId={occurrence.event.id}
isSubscribed={isChildHasActiveSubscription}
occurrence={occurrence}
onUnsubscribed={onUnsubscribed}
onSubscribe={onSubscribe}
onSubscribed={onSubscribed}
unsubscribeLabel={t(
'enrollment.button.cancelNotificationSubscription'
)}
subscribeLabel={t(
'enrollment.button.occurrenceFullSubscribeToNotifications'
)}
/>
)}
<Button onClick={onCancel} variant="secondary">
{t('enrollment.confirmationPage.cancel.button')}
</Button>
</div>
</div>
</>
);
};
export default Enrol;