richie-education 3.2.1-dev9 → 3.2.2-dev26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/i18n/locales/ar-SA.json +29 -1
- package/i18n/locales/es-ES.json +29 -1
- package/i18n/locales/fa-IR.json +29 -1
- package/i18n/locales/fr-CA.json +29 -1
- package/i18n/locales/fr-FR.json +29 -1
- package/i18n/locales/ko-KR.json +29 -1
- package/i18n/locales/pt-PT.json +29 -1
- package/i18n/locales/ru-RU.json +29 -1
- package/i18n/locales/vi-VN.json +29 -1
- package/js/api/joanie.ts +144 -0
- package/js/components/PaymentInterfaces/types.ts +7 -0
- package/js/components/PaymentScheduleGrid/index.tsx +4 -2
- package/js/components/SaleTunnel/AddressSelector/index.spec.tsx +9 -2
- package/js/components/SaleTunnel/GenericSaleTunnel.tsx +33 -0
- package/js/components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationGroup.tsx +253 -0
- package/js/components/SaleTunnel/SaleTunnelInformation/SaleTunnelInformationSingular.tsx +314 -0
- package/js/components/SaleTunnel/SaleTunnelInformation/StepContent.tsx +528 -0
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +47 -261
- package/js/components/SaleTunnel/SaleTunnelSuccess/index.tsx +25 -11
- package/js/components/SaleTunnel/SubscriptionButton/index.tsx +54 -6
- package/js/components/SaleTunnel/_styles.scss +55 -0
- package/js/components/SaleTunnel/index.full-process-b2b.spec.tsx +356 -0
- package/js/components/SaleTunnel/{index.full-process.spec.tsx → index.full-process-b2c.spec.tsx} +4 -1
- package/js/components/SaleTunnel/index.spec.tsx +130 -1
- package/js/hooks/useBatchOrder/index.tsx +36 -0
- package/js/hooks/useContractArchive/index.ts +2 -0
- package/js/hooks/useOfferingOrganizations/index.tsx +38 -0
- package/js/hooks/useOrganizationAgreements.tsx/index.tsx +66 -0
- package/js/hooks/useOrganizationQuotes/index.tsx +56 -0
- package/js/hooks/usePaymentPlan.tsx +2 -1
- package/js/hooks/useTeacherPendingAgreementsCount/index.ts +34 -0
- package/js/pages/DashboardBatchOrderLayout/_styles.scss +5 -0
- package/js/pages/DashboardBatchOrderLayout/index.spec.tsx +78 -0
- package/js/pages/DashboardBatchOrderLayout/index.tsx +45 -0
- package/js/pages/DashboardBatchOrders/index.spec.tsx +237 -0
- package/js/pages/DashboardBatchOrders/index.tsx +84 -0
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardCourseContractsLayout/index.tsx +0 -1
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +3 -1
- package/js/pages/TeacherDashboardOrganizationAgreements/AgreementActionsBar.tsx +49 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/BulkAgreementContractButton.tsx +79 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/OrganizationAgreementFrame.tsx +71 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/SignOrganizationAgreementButton.tsx +60 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/hooks/useAgreementsAbilities.tsx +8 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/hooks/useHasAgreementToDownload.tsx +27 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/hooks/useTeacherAgreementsToSign.tsx +32 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/index.spec.tsx +433 -0
- package/js/pages/TeacherDashboardOrganizationAgreements/index.tsx +130 -0
- package/js/pages/TeacherDashboardOrganizationAgreementsLayout/index.tsx +25 -0
- package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +9 -0
- package/js/pages/TeacherDashboardOrganizationQuotes/_styles.scss +40 -0
- package/js/pages/TeacherDashboardOrganizationQuotes/index.full-process.spec.tsx +194 -0
- package/js/pages/TeacherDashboardOrganizationQuotes/index.spec.tsx +144 -0
- package/js/pages/TeacherDashboardOrganizationQuotes/index.tsx +521 -0
- package/js/pages/TeacherDashboardOrganizationQuotesLayout/index.tsx +26 -0
- package/js/translations/ar-SA.json +1 -1
- package/js/translations/es-ES.json +1 -1
- package/js/translations/fa-IR.json +1 -1
- package/js/translations/fr-CA.json +1 -1
- package/js/translations/fr-FR.json +1 -1
- package/js/translations/ko-KR.json +1 -1
- package/js/translations/pt-PT.json +1 -1
- package/js/translations/ru-RU.json +1 -1
- package/js/translations/vi-VN.json +1 -1
- package/js/types/Joanie.ts +216 -1
- package/js/utils/AbilitiesHelper/agreementAbilities.ts +14 -0
- package/js/utils/AbilitiesHelper/index.ts +7 -0
- package/js/utils/AbilitiesHelper/types.ts +12 -3
- package/js/utils/ObjectHelper/index.ts +20 -0
- package/js/utils/OrderHelper/index.ts +10 -0
- package/js/utils/errors/HttpError.ts +1 -0
- package/js/utils/test/factories/joanie.ts +156 -1
- package/js/widgets/Dashboard/components/DashboardBatchOrderLoader/_styles.scss +14 -0
- package/js/widgets/Dashboard/components/DashboardBatchOrderLoader/index.tsx +32 -0
- package/js/widgets/Dashboard/components/DashboardCard/index.spec.tsx +18 -0
- package/js/widgets/Dashboard/components/DashboardCard/index.stories.tsx +25 -2
- package/js/widgets/Dashboard/components/DashboardCard/index.tsx +4 -2
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/BatchOrderPaymentModal/BatchOrderPaymentManager.tsx +88 -0
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/BatchOrderPaymentModal/index.tsx +216 -0
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/DashboardBatchOrderSubItems.tsx +316 -0
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/index.spec.tsx +27 -0
- package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/index.tsx +175 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +5 -2
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrganizationBlock/index.tsx +4 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/_styles.scss +5 -0
- package/js/widgets/Dashboard/components/DashboardItem/_styles.scss +43 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/AgreementNavLink/index.spec.tsx +214 -0
- package/js/widgets/Dashboard/components/DashboardSidebar/components/AgreementNavLink/index.tsx +47 -0
- package/js/widgets/Dashboard/components/LearnerDashboardSidebar/index.tsx +1 -0
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.spec.tsx +21 -3
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +9 -0
- package/js/widgets/Dashboard/utils/learnerRoutes.tsx +30 -0
- package/js/widgets/Dashboard/utils/learnerRoutesPaths.tsx +12 -0
- package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +12 -0
- package/js/widgets/Dashboard/utils/teacherRoutes.tsx +17 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +8 -2
- package/package.json +4 -1
- package/scss/colors/_theme.scss +1 -1
- package/scss/components/_index.scss +1 -0
package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/BatchOrderPaymentModal/index.tsx
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Alert,
|
|
3
|
+
Button,
|
|
4
|
+
Modal,
|
|
5
|
+
ModalProps,
|
|
6
|
+
ModalSize,
|
|
7
|
+
useModals,
|
|
8
|
+
VariantType,
|
|
9
|
+
} from '@openfun/cunningham-react';
|
|
10
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
11
|
+
import { useRef, useState } from 'react';
|
|
12
|
+
import { BatchOrderRead, BatchOrderState } from 'types/Joanie';
|
|
13
|
+
import { useJoanieApi } from 'contexts/JoanieApiContext';
|
|
14
|
+
import { Payment, PaymentErrorMessageId } from 'components/PaymentInterfaces/types';
|
|
15
|
+
import PaymentInterface from 'components/PaymentInterfaces';
|
|
16
|
+
import { PAYMENT_SETTINGS } from 'settings';
|
|
17
|
+
import { Spinner } from 'components/Spinner';
|
|
18
|
+
import { useBatchOrders, useBatchOrdersActions } from 'hooks/useBatchOrder';
|
|
19
|
+
|
|
20
|
+
const messages = defineMessages({
|
|
21
|
+
title: {
|
|
22
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.title',
|
|
23
|
+
defaultMessage: 'Batch order payment',
|
|
24
|
+
description: 'Title of the modal prompting the user to complete a batch order payment.',
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.description',
|
|
28
|
+
defaultMessage:
|
|
29
|
+
'Since you selected payment by credit card, please finalize your batch order to complete the process.',
|
|
30
|
+
description:
|
|
31
|
+
'Informational message displayed when the user needs to complete the batch order payment.',
|
|
32
|
+
},
|
|
33
|
+
submit: {
|
|
34
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.submit',
|
|
35
|
+
defaultMessage: 'Pay {amount}',
|
|
36
|
+
description: 'Label of the button used to start the batch order payment.',
|
|
37
|
+
},
|
|
38
|
+
paymentInProgress: {
|
|
39
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.paymentInProgress',
|
|
40
|
+
defaultMessage: 'Payment in progress',
|
|
41
|
+
description: 'Label displayed when the payment process is currently ongoing.',
|
|
42
|
+
},
|
|
43
|
+
paymentError: {
|
|
44
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.paymentError',
|
|
45
|
+
defaultMessage: 'An error occurred during the payment process.',
|
|
46
|
+
description: 'Error message displayed when the payment fails.',
|
|
47
|
+
},
|
|
48
|
+
successTitle: {
|
|
49
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.successTitle',
|
|
50
|
+
defaultMessage: 'Payment successful',
|
|
51
|
+
description: 'Title of the modal displayed when the payment completes successfully.',
|
|
52
|
+
},
|
|
53
|
+
successDescription: {
|
|
54
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.successDescription',
|
|
55
|
+
defaultMessage: 'Your payment has been processed successfully.',
|
|
56
|
+
description: 'Description displayed in the success modal after a successful payment.',
|
|
57
|
+
},
|
|
58
|
+
abortError: {
|
|
59
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.abortError',
|
|
60
|
+
defaultMessage: 'Your payment was aborted during the process. Please try again.',
|
|
61
|
+
description:
|
|
62
|
+
'Error message displayed when the payment process is aborted by the user or system.',
|
|
63
|
+
},
|
|
64
|
+
errorAbortingPolling: {
|
|
65
|
+
id: 'components.DashboardItemBatchOrder.BatchOrderPaymentModal.errorAbortingPolling',
|
|
66
|
+
defaultMessage:
|
|
67
|
+
'Your payment was successful, but order validation is taking longer than expected. You can close this dialog and check your order later.',
|
|
68
|
+
description:
|
|
69
|
+
'Message displayed when the payment succeeded but the order validation polling timed out.',
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
interface Props extends Pick<ModalProps, 'isOpen' | 'onClose'> {
|
|
74
|
+
batchOrder: BatchOrderRead;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
enum ComponentStates {
|
|
78
|
+
IDLE = 'idle',
|
|
79
|
+
LOADING = 'loading',
|
|
80
|
+
ERROR = 'error',
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export const BatchOrderPaymentModal = ({ batchOrder, ...props }: Props) => {
|
|
84
|
+
const intl = useIntl();
|
|
85
|
+
const API = useJoanieApi();
|
|
86
|
+
const timeoutRef = useRef<NodeJS.Timeout>(undefined);
|
|
87
|
+
const { methods: batchOrderMethods } = useBatchOrders();
|
|
88
|
+
const [payment, setPayment] = useState<Payment>();
|
|
89
|
+
const [state, setState] = useState<ComponentStates>(ComponentStates.IDLE);
|
|
90
|
+
const [error, setError] = useState<string>();
|
|
91
|
+
|
|
92
|
+
const modals = useModals();
|
|
93
|
+
const { submitForPayment } = useBatchOrdersActions();
|
|
94
|
+
const pay = async () => {
|
|
95
|
+
setState(ComponentStates.LOADING);
|
|
96
|
+
try {
|
|
97
|
+
const paymentResponse = await submitForPayment({
|
|
98
|
+
id: batchOrder.id,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
if (paymentResponse) {
|
|
102
|
+
setPayment(paymentResponse);
|
|
103
|
+
} else {
|
|
104
|
+
// In case of bug.
|
|
105
|
+
setError(intl.formatMessage(messages.paymentError));
|
|
106
|
+
setState(ComponentStates.ERROR);
|
|
107
|
+
}
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
109
|
+
} catch (_error) {
|
|
110
|
+
setError(intl.formatMessage(messages.paymentError));
|
|
111
|
+
setState(ComponentStates.ERROR);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const handleError = (messageId: string = PaymentErrorMessageId.ERROR_DEFAULT) => {
|
|
116
|
+
setState(ComponentStates.ERROR);
|
|
117
|
+
|
|
118
|
+
if (messageId === PaymentErrorMessageId.ERROR_ABORT) {
|
|
119
|
+
setError(intl.formatMessage(messages.abortError));
|
|
120
|
+
} else {
|
|
121
|
+
setError(intl.formatMessage(messages.paymentError));
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const isBatchOrderValidated = async (id: string): Promise<Boolean> => {
|
|
126
|
+
const batchOrderToCheck = await API.user.batchOrders.get({ id });
|
|
127
|
+
return batchOrderToCheck !== null && batchOrderToCheck.state === BatchOrderState.COMPLETED;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const settled = async () => {
|
|
131
|
+
await batchOrderMethods.invalidate();
|
|
132
|
+
props.onClose();
|
|
133
|
+
await modals.messageModal({
|
|
134
|
+
messageType: VariantType.SUCCESS,
|
|
135
|
+
title: intl.formatMessage(messages.successTitle),
|
|
136
|
+
children: intl.formatMessage(messages.successDescription),
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleSuccess = () => {
|
|
141
|
+
let round = 0;
|
|
142
|
+
|
|
143
|
+
const checkBatchOrderValidity = async () => {
|
|
144
|
+
if (round >= PAYMENT_SETTINGS.pollLimit) {
|
|
145
|
+
timeoutRef.current = undefined;
|
|
146
|
+
setState(ComponentStates.ERROR);
|
|
147
|
+
setError(intl.formatMessage(messages.errorAbortingPolling));
|
|
148
|
+
} else {
|
|
149
|
+
const isValidated = await isBatchOrderValidated(batchOrder.id);
|
|
150
|
+
if (isValidated) {
|
|
151
|
+
setState(ComponentStates.IDLE);
|
|
152
|
+
timeoutRef.current = undefined;
|
|
153
|
+
settled();
|
|
154
|
+
} else {
|
|
155
|
+
round++;
|
|
156
|
+
timeoutRef.current = setTimeout(checkBatchOrderValidity, PAYMENT_SETTINGS.pollInterval);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
checkBatchOrderValidity();
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
return (
|
|
165
|
+
<>
|
|
166
|
+
<Modal
|
|
167
|
+
{...props}
|
|
168
|
+
size={ModalSize.MEDIUM}
|
|
169
|
+
title={intl.formatMessage(messages.title)}
|
|
170
|
+
closeOnEsc={state !== ComponentStates.LOADING}
|
|
171
|
+
preventClose={state === ComponentStates.LOADING}
|
|
172
|
+
hideCloseButton={state === ComponentStates.LOADING}
|
|
173
|
+
actions={
|
|
174
|
+
<Button
|
|
175
|
+
color="primary"
|
|
176
|
+
size="small"
|
|
177
|
+
fullWidth={true}
|
|
178
|
+
onClick={pay}
|
|
179
|
+
disabled={state === ComponentStates.LOADING}
|
|
180
|
+
data-testid="order-payment-retry-modal-submit-button"
|
|
181
|
+
>
|
|
182
|
+
{state === ComponentStates.LOADING ? (
|
|
183
|
+
<Spinner theme="light" aria-labelledby="payment-in-progress">
|
|
184
|
+
<span id="payment-in-progress">
|
|
185
|
+
<FormattedMessage {...messages.paymentInProgress} />
|
|
186
|
+
</span>
|
|
187
|
+
</Spinner>
|
|
188
|
+
) : (
|
|
189
|
+
<FormattedMessage
|
|
190
|
+
{...messages.submit}
|
|
191
|
+
values={{
|
|
192
|
+
amount: intl.formatNumber(batchOrder.total ?? 0, {
|
|
193
|
+
style: 'currency',
|
|
194
|
+
currency: batchOrder.currency ?? 'EUR',
|
|
195
|
+
}),
|
|
196
|
+
}}
|
|
197
|
+
/>
|
|
198
|
+
)}
|
|
199
|
+
</Button>
|
|
200
|
+
}
|
|
201
|
+
>
|
|
202
|
+
{error && (
|
|
203
|
+
<Alert type={VariantType.ERROR} className="mb-t">
|
|
204
|
+
{error}
|
|
205
|
+
</Alert>
|
|
206
|
+
)}
|
|
207
|
+
{!error && (
|
|
208
|
+
<Alert className="mb-b">
|
|
209
|
+
<FormattedMessage {...messages.description} />
|
|
210
|
+
</Alert>
|
|
211
|
+
)}
|
|
212
|
+
</Modal>
|
|
213
|
+
{payment && <PaymentInterface {...payment} onError={handleError} onSuccess={handleSuccess} />}
|
|
214
|
+
</>
|
|
215
|
+
);
|
|
216
|
+
};
|
package/js/widgets/Dashboard/components/DashboardItem/BatchOrder/DashboardBatchOrderSubItems.tsx
ADDED
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
2
|
+
import { PaymentMethod } from 'components/PaymentInterfaces/types';
|
|
3
|
+
import { BatchOrderRead } from 'types/Joanie';
|
|
4
|
+
import { DashboardSubItem } from 'widgets/Dashboard/components/DashboardItem/DashboardSubItem';
|
|
5
|
+
import { DashboardSubItemsList } from '../DashboardSubItemsList';
|
|
6
|
+
|
|
7
|
+
const messages = defineMessages({
|
|
8
|
+
stepCompany: {
|
|
9
|
+
id: 'batchOrder.title.company',
|
|
10
|
+
description: 'Step label for company information in the batch order form',
|
|
11
|
+
defaultMessage: 'Organization',
|
|
12
|
+
},
|
|
13
|
+
stepAdmin: {
|
|
14
|
+
id: 'batchOrder.title.admin',
|
|
15
|
+
description: 'Step label for administrative follow-up in the batch order form',
|
|
16
|
+
defaultMessage: 'Follow-up',
|
|
17
|
+
},
|
|
18
|
+
stepParticipants: {
|
|
19
|
+
id: 'batchOrder.title.partipants',
|
|
20
|
+
description: 'Step label for participants information in the batch order form',
|
|
21
|
+
defaultMessage: 'Participants',
|
|
22
|
+
},
|
|
23
|
+
stepFinancing: {
|
|
24
|
+
id: 'batchOrder.title.financing',
|
|
25
|
+
description: 'Step label for financing/payment in the batch order form',
|
|
26
|
+
defaultMessage: 'Financing',
|
|
27
|
+
},
|
|
28
|
+
stepSignatory: {
|
|
29
|
+
id: 'batchOrder.title.signatory',
|
|
30
|
+
description: 'section with details about the person responsible for signing the quote',
|
|
31
|
+
defaultMessage: 'Signatory',
|
|
32
|
+
},
|
|
33
|
+
seats: {
|
|
34
|
+
id: 'batchOrder.seats',
|
|
35
|
+
description: 'Text displayed for seats value in batch order',
|
|
36
|
+
defaultMessage: 'Seats',
|
|
37
|
+
},
|
|
38
|
+
labelName: {
|
|
39
|
+
id: 'batchOrder.label.name',
|
|
40
|
+
description: 'Label displayed for the name field in batch order form',
|
|
41
|
+
defaultMessage: 'Name',
|
|
42
|
+
},
|
|
43
|
+
labelProfession: {
|
|
44
|
+
id: 'batchOrder.label.profession',
|
|
45
|
+
description: 'Label displayed for the profession field in batch order form',
|
|
46
|
+
defaultMessage: 'Profession',
|
|
47
|
+
},
|
|
48
|
+
labelEmail: {
|
|
49
|
+
id: 'batchOrder.label.email',
|
|
50
|
+
description: 'Label displayed for the email field in batch order form',
|
|
51
|
+
defaultMessage: 'Email',
|
|
52
|
+
},
|
|
53
|
+
labelPhone: {
|
|
54
|
+
id: 'batchOrder.label.phone',
|
|
55
|
+
description: 'Label displayed for the phone field in batch order form',
|
|
56
|
+
defaultMessage: 'Phone',
|
|
57
|
+
},
|
|
58
|
+
labelMethod: {
|
|
59
|
+
id: 'batchOrder.label.method',
|
|
60
|
+
description: 'Label displayed for the payment method field in batch order form',
|
|
61
|
+
defaultMessage: 'Method',
|
|
62
|
+
},
|
|
63
|
+
labelEntity: {
|
|
64
|
+
id: 'batchOrder.label.entity',
|
|
65
|
+
description: 'Label displayed for the entity field in batch order form',
|
|
66
|
+
defaultMessage: 'Entity',
|
|
67
|
+
},
|
|
68
|
+
labelAmount: {
|
|
69
|
+
id: 'batchOrder.label.amount',
|
|
70
|
+
description: 'Label displayed for the amount field in batch order form',
|
|
71
|
+
defaultMessage: 'Amount',
|
|
72
|
+
},
|
|
73
|
+
labelCompany: {
|
|
74
|
+
id: 'batchOrder.label.company',
|
|
75
|
+
description: 'Label displayed for the company field in batch order form',
|
|
76
|
+
defaultMessage: 'Company',
|
|
77
|
+
},
|
|
78
|
+
labelSiret: {
|
|
79
|
+
id: 'batchOrder.label.siret',
|
|
80
|
+
description: 'Label displayed for the SIRET field in batch order form',
|
|
81
|
+
defaultMessage: 'SIRET',
|
|
82
|
+
},
|
|
83
|
+
labelVAT: {
|
|
84
|
+
id: 'batchOrder.label.vat',
|
|
85
|
+
description: 'Label displayed for the VAT field in batch order form',
|
|
86
|
+
defaultMessage: 'VAT',
|
|
87
|
+
},
|
|
88
|
+
labelAddress: {
|
|
89
|
+
id: 'batchOrder.label.address',
|
|
90
|
+
description: 'Label displayed for the address field in batch order form',
|
|
91
|
+
defaultMessage: 'Address',
|
|
92
|
+
},
|
|
93
|
+
labelPostcode: {
|
|
94
|
+
id: 'batchOrder.label.postcode',
|
|
95
|
+
description: 'Label displayed for the postcode field in batch order form',
|
|
96
|
+
defaultMessage: 'Postcode',
|
|
97
|
+
},
|
|
98
|
+
labelCity: {
|
|
99
|
+
id: 'batchOrder.label.city',
|
|
100
|
+
description: 'Label displayed for the city field in batch order form',
|
|
101
|
+
defaultMessage: 'City',
|
|
102
|
+
},
|
|
103
|
+
labelCountry: {
|
|
104
|
+
id: 'batchOrder.label.country',
|
|
105
|
+
description: 'Label displayed for the country field in batch order form',
|
|
106
|
+
defaultMessage: 'Country',
|
|
107
|
+
},
|
|
108
|
+
labelBilling: {
|
|
109
|
+
id: 'batchOrder.label.billing',
|
|
110
|
+
description: 'Label displayed for the billing field in batch order form',
|
|
111
|
+
defaultMessage: 'Billing',
|
|
112
|
+
},
|
|
113
|
+
[PaymentMethod.BANK_TRANSFER]: {
|
|
114
|
+
id: 'batchOrder.payment.bank',
|
|
115
|
+
description: 'Label for bank transfer payment method',
|
|
116
|
+
defaultMessage: 'Bank transfer',
|
|
117
|
+
},
|
|
118
|
+
[PaymentMethod.CARD_PAYMENT]: {
|
|
119
|
+
id: 'batchOrder.payment.card',
|
|
120
|
+
description: 'Label for card payment method',
|
|
121
|
+
defaultMessage: 'Card payment',
|
|
122
|
+
},
|
|
123
|
+
[PaymentMethod.PURCHASE_ORDER]: {
|
|
124
|
+
id: 'batchOrder.payment.order',
|
|
125
|
+
description: 'Label for purchase order payment method',
|
|
126
|
+
defaultMessage: 'Purchase order',
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
const DashboardItemField = ({
|
|
131
|
+
label,
|
|
132
|
+
value,
|
|
133
|
+
}: {
|
|
134
|
+
label: React.ReactNode;
|
|
135
|
+
value?: React.ReactNode;
|
|
136
|
+
}) =>
|
|
137
|
+
value ? (
|
|
138
|
+
<div>
|
|
139
|
+
<span className="dashboard-item__label">{label}: </span>
|
|
140
|
+
{value}
|
|
141
|
+
</div>
|
|
142
|
+
) : null;
|
|
143
|
+
|
|
144
|
+
export const DashboardBatchOrderSubItems = ({ batchOrder }: { batchOrder: BatchOrderRead }) => {
|
|
145
|
+
const intl = useIntl();
|
|
146
|
+
|
|
147
|
+
const items = [
|
|
148
|
+
<DashboardSubItem
|
|
149
|
+
key="company"
|
|
150
|
+
title={intl.formatMessage(messages.stepCompany)}
|
|
151
|
+
footer={
|
|
152
|
+
<div className="content">
|
|
153
|
+
<DashboardItemField
|
|
154
|
+
label={<FormattedMessage {...messages.labelCompany} />}
|
|
155
|
+
value={batchOrder.company_name}
|
|
156
|
+
/>
|
|
157
|
+
<DashboardItemField
|
|
158
|
+
label={<FormattedMessage {...messages.labelSiret} />}
|
|
159
|
+
value={batchOrder.identification_number}
|
|
160
|
+
/>
|
|
161
|
+
<DashboardItemField
|
|
162
|
+
label={<FormattedMessage {...messages.labelVAT} />}
|
|
163
|
+
value={batchOrder.vat_registration}
|
|
164
|
+
/>
|
|
165
|
+
<DashboardItemField
|
|
166
|
+
label={<FormattedMessage {...messages.labelAddress} />}
|
|
167
|
+
value={batchOrder.address}
|
|
168
|
+
/>
|
|
169
|
+
<DashboardItemField
|
|
170
|
+
label={<FormattedMessage {...messages.labelPostcode} />}
|
|
171
|
+
value={batchOrder.postcode}
|
|
172
|
+
/>
|
|
173
|
+
<DashboardItemField
|
|
174
|
+
label={<FormattedMessage {...messages.labelCity} />}
|
|
175
|
+
value={batchOrder.city}
|
|
176
|
+
/>
|
|
177
|
+
<DashboardItemField
|
|
178
|
+
label={<FormattedMessage {...messages.labelCountry} />}
|
|
179
|
+
value={batchOrder.country}
|
|
180
|
+
/>
|
|
181
|
+
</div>
|
|
182
|
+
}
|
|
183
|
+
/>,
|
|
184
|
+
<DashboardSubItem
|
|
185
|
+
key="admin"
|
|
186
|
+
title={intl.formatMessage(messages.stepAdmin)}
|
|
187
|
+
footer={
|
|
188
|
+
<div className="content">
|
|
189
|
+
<DashboardItemField
|
|
190
|
+
label={<FormattedMessage {...messages.labelName} />}
|
|
191
|
+
value={`${batchOrder.administrative_firstname} ${batchOrder.administrative_lastname}`}
|
|
192
|
+
/>
|
|
193
|
+
<DashboardItemField
|
|
194
|
+
label={<FormattedMessage {...messages.labelProfession} />}
|
|
195
|
+
value={batchOrder.administrative_profession}
|
|
196
|
+
/>
|
|
197
|
+
<DashboardItemField
|
|
198
|
+
label={<FormattedMessage {...messages.labelEmail} />}
|
|
199
|
+
value={batchOrder.administrative_email}
|
|
200
|
+
/>
|
|
201
|
+
<DashboardItemField
|
|
202
|
+
label={<FormattedMessage {...messages.labelPhone} />}
|
|
203
|
+
value={batchOrder.administrative_telephone}
|
|
204
|
+
/>
|
|
205
|
+
</div>
|
|
206
|
+
}
|
|
207
|
+
/>,
|
|
208
|
+
<DashboardSubItem
|
|
209
|
+
key="signatory"
|
|
210
|
+
title={intl.formatMessage(messages.stepSignatory)}
|
|
211
|
+
footer={
|
|
212
|
+
<div className="content">
|
|
213
|
+
<DashboardItemField
|
|
214
|
+
label={<FormattedMessage {...messages.labelName} />}
|
|
215
|
+
value={`${batchOrder.signatory_firstname} ${batchOrder.signatory_lastname}`}
|
|
216
|
+
/>
|
|
217
|
+
<DashboardItemField
|
|
218
|
+
label={<FormattedMessage {...messages.labelProfession} />}
|
|
219
|
+
value={batchOrder.signatory_profession}
|
|
220
|
+
/>
|
|
221
|
+
<DashboardItemField
|
|
222
|
+
label={<FormattedMessage {...messages.labelEmail} />}
|
|
223
|
+
value={batchOrder.signatory_email}
|
|
224
|
+
/>
|
|
225
|
+
<DashboardItemField
|
|
226
|
+
label={<FormattedMessage {...messages.labelPhone} />}
|
|
227
|
+
value={batchOrder.signatory_telephone}
|
|
228
|
+
/>
|
|
229
|
+
</div>
|
|
230
|
+
}
|
|
231
|
+
/>,
|
|
232
|
+
<DashboardSubItem
|
|
233
|
+
key="participants"
|
|
234
|
+
title={intl.formatMessage(messages.stepParticipants)}
|
|
235
|
+
footer={
|
|
236
|
+
<div className="content">
|
|
237
|
+
<DashboardItemField
|
|
238
|
+
label={<FormattedMessage {...messages.seats} />}
|
|
239
|
+
value={batchOrder.nb_seats}
|
|
240
|
+
/>
|
|
241
|
+
</div>
|
|
242
|
+
}
|
|
243
|
+
/>,
|
|
244
|
+
<DashboardSubItem
|
|
245
|
+
key="financing"
|
|
246
|
+
title={intl.formatMessage(messages.stepFinancing)}
|
|
247
|
+
footer={
|
|
248
|
+
<div className="content">
|
|
249
|
+
<DashboardItemField
|
|
250
|
+
label={<FormattedMessage {...messages.labelMethod} />}
|
|
251
|
+
value={
|
|
252
|
+
batchOrder.payment_method && (
|
|
253
|
+
<FormattedMessage {...messages[batchOrder.payment_method]} />
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
/>
|
|
257
|
+
<DashboardItemField
|
|
258
|
+
label={<FormattedMessage {...messages.labelEntity} />}
|
|
259
|
+
value={batchOrder.funding_entity}
|
|
260
|
+
/>
|
|
261
|
+
<DashboardItemField
|
|
262
|
+
label={<FormattedMessage {...messages.labelAmount} />}
|
|
263
|
+
value={batchOrder.funding_amount}
|
|
264
|
+
/>
|
|
265
|
+
</div>
|
|
266
|
+
}
|
|
267
|
+
/>,
|
|
268
|
+
];
|
|
269
|
+
|
|
270
|
+
if (batchOrder.billing_address) {
|
|
271
|
+
items.push(
|
|
272
|
+
<DashboardSubItem
|
|
273
|
+
key="billing"
|
|
274
|
+
title={intl.formatMessage(messages.labelBilling)}
|
|
275
|
+
footer={
|
|
276
|
+
<div className="content">
|
|
277
|
+
<DashboardItemField
|
|
278
|
+
label={<FormattedMessage {...messages.labelCompany} />}
|
|
279
|
+
value={batchOrder.billing_address.company_name}
|
|
280
|
+
/>
|
|
281
|
+
<DashboardItemField
|
|
282
|
+
label={<FormattedMessage {...messages.labelSiret} />}
|
|
283
|
+
value={batchOrder.billing_address.identification_number}
|
|
284
|
+
/>
|
|
285
|
+
<DashboardItemField
|
|
286
|
+
label={<FormattedMessage {...messages.labelName} />}
|
|
287
|
+
value={batchOrder.billing_address.contact_name}
|
|
288
|
+
/>
|
|
289
|
+
<DashboardItemField
|
|
290
|
+
label={<FormattedMessage {...messages.labelEmail} />}
|
|
291
|
+
value={batchOrder.billing_address.contact_email}
|
|
292
|
+
/>
|
|
293
|
+
<DashboardItemField
|
|
294
|
+
label={<FormattedMessage {...messages.labelAddress} />}
|
|
295
|
+
value={batchOrder.billing_address.address}
|
|
296
|
+
/>
|
|
297
|
+
<DashboardItemField
|
|
298
|
+
label={<FormattedMessage {...messages.labelPostcode} />}
|
|
299
|
+
value={batchOrder.billing_address.postcode}
|
|
300
|
+
/>
|
|
301
|
+
<DashboardItemField
|
|
302
|
+
label={<FormattedMessage {...messages.labelCity} />}
|
|
303
|
+
value={batchOrder.billing_address.city}
|
|
304
|
+
/>
|
|
305
|
+
<DashboardItemField
|
|
306
|
+
label={<FormattedMessage {...messages.labelCountry} />}
|
|
307
|
+
value={batchOrder.billing_address.country}
|
|
308
|
+
/>
|
|
309
|
+
</div>
|
|
310
|
+
}
|
|
311
|
+
/>,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
return <DashboardSubItemsList subItems={items} />;
|
|
316
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import fetchMock from 'fetch-mock';
|
|
2
|
+
import { screen } from '@testing-library/react';
|
|
3
|
+
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
4
|
+
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
5
|
+
import { render } from 'utils/test/render';
|
|
6
|
+
import { BatchOrderReadFactory } from 'utils/test/factories/joanie';
|
|
7
|
+
import { DashboardItemBatchOrder } from '.';
|
|
8
|
+
|
|
9
|
+
jest.mock('utils/context', () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: mockRichieContextFactory({
|
|
12
|
+
authentication: { backend: 'fonzie', endpoint: 'https://auth.test' },
|
|
13
|
+
joanie_backend: { endpoint: 'https://joanie.endpoint' },
|
|
14
|
+
}).one(),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
describe('<DashboardItemBatchOrder />', () => {
|
|
18
|
+
setupJoanieSession();
|
|
19
|
+
|
|
20
|
+
it('renders a batch order', async () => {
|
|
21
|
+
const batchOrder = BatchOrderReadFactory().one();
|
|
22
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/batch-orders/`, [batchOrder]);
|
|
23
|
+
fetchMock.get(`https://joanie.endpoint/api/v1.0/batch-orders/${batchOrder.id}/`, batchOrder);
|
|
24
|
+
render(<DashboardItemBatchOrder batchOrder={batchOrder} />);
|
|
25
|
+
expect(await screen.findByText(batchOrder.offering?.product.title)).toBeVisible();
|
|
26
|
+
});
|
|
27
|
+
});
|