richie-education 2.29.2 → 2.29.3-dev48
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 +193 -125
- package/i18n/locales/es-ES.json +193 -125
- package/i18n/locales/fa-IR.json +193 -125
- package/i18n/locales/fr-CA.json +193 -125
- package/i18n/locales/fr-FR.json +193 -125
- package/i18n/locales/ko-KR.json +193 -125
- package/i18n/locales/pt-PT.json +193 -125
- package/i18n/locales/ru-RU.json +193 -125
- package/i18n/locales/vi-VN.json +193 -125
- package/js/api/joanie.ts +42 -17
- package/js/api/lms/dummy.ts +1 -12
- package/js/components/ContractFrame/AbstractContractFrame.spec.tsx +16 -9
- package/js/components/ContractFrame/AbstractContractFrame.tsx +28 -23
- package/js/components/ContractFrame/LearnerContractFrame.tsx +2 -2
- package/js/components/ContractFrame/_styles.scss +6 -14
- package/js/components/ContractStatus/index.spec.tsx +1 -1
- package/js/components/ContractStatus/index.tsx +1 -1
- package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/index.spec.tsx +15 -45
- package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/index.tsx +19 -26
- package/js/components/DownloadContractButton/index.spec.tsx +1 -1
- package/js/components/Form/utils.ts +2 -1
- package/js/components/OpenEdxFullNameForm/index.spec.tsx +229 -0
- package/js/components/OpenEdxFullNameForm/index.tsx +7 -7
- package/js/components/PaymentInterfaces/LyraPopIn.tsx +2 -2
- package/js/components/PaymentInterfaces/PayplugLightbox.tsx +1 -1
- package/js/components/PaymentInterfaces/__mocks__/index.tsx +1 -4
- package/js/components/PaymentInterfaces/types.ts +5 -2
- package/js/components/PaymentScheduleGrid/_styles.scss +13 -0
- package/js/components/PaymentScheduleGrid/index.tsx +50 -70
- package/js/components/PurchaseButton/index.spec.tsx +84 -37
- package/js/components/PurchaseButton/index.tsx +9 -27
- package/js/components/SaleTunnel/AddressSelector/index.spec.tsx +2 -2
- package/js/components/SaleTunnel/CertificateSaleTunnel/index.tsx +2 -2
- package/js/components/SaleTunnel/CredentialSaleTunnel/index.tsx +6 -10
- package/js/components/SaleTunnel/GenericSaleTunnel.tsx +105 -48
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +16 -20
- package/js/components/SaleTunnel/SaleTunnelSavePaymentMethod/_styles.scss +12 -0
- package/js/components/SaleTunnel/SaleTunnelSavePaymentMethod/index.tsx +157 -0
- package/js/components/SaleTunnel/SaleTunnelSuccess/index.tsx +15 -29
- package/js/components/SaleTunnel/Sponsors/SaleTunnelSponsors.scss +4 -5
- package/js/components/SaleTunnel/Sponsors/SaleTunnelSponsors.tsx +39 -11
- package/js/components/SaleTunnel/SubscriptionButton/_styles.scss +7 -0
- package/js/components/SaleTunnel/SubscriptionButton/index.tsx +202 -0
- package/js/components/SaleTunnel/_styles.scss +16 -5
- package/js/components/SaleTunnel/hooks/useTerms.tsx +0 -77
- package/js/components/SaleTunnel/index.credential.spec.tsx +14 -25
- package/js/components/SaleTunnel/index.full-process.spec.tsx +114 -48
- package/js/components/SaleTunnel/index.spec.tsx +333 -717
- package/js/components/SaleTunnel/index.tsx +2 -1
- package/js/components/SignContractButton/index.omniscientOrders.spec.tsx +16 -11
- package/js/components/SignContractButton/index.spec.tsx +16 -20
- package/js/components/SignContractButton/index.tsx +3 -1
- package/js/hooks/useCreditCards/index.spec.tsx +70 -6
- package/js/hooks/useCreditCards/index.ts +49 -11
- package/js/hooks/useOrders/index.spec.tsx +322 -0
- package/js/hooks/{useOrders.ts → useOrders/index.ts} +40 -14
- package/js/hooks/usePaymentSchedule.tsx +23 -0
- package/js/hooks/useProductOrder/index.spec.tsx +77 -60
- package/js/hooks/useProductOrder/index.tsx +2 -2
- package/js/hooks/useResources/useResourcesRoot.ts +4 -3
- package/js/index.tsx +2 -0
- package/js/pages/DashboardCreditCardsManagement/CreditCardBrandLogo.spec.tsx +1 -1
- package/js/pages/DashboardCreditCardsManagement/CreditCardBrandLogo.tsx +4 -2
- package/js/pages/DashboardOrderLayout/index.spec.tsx +10 -1
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +8 -5
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +8 -9
- package/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.spec.tsx +1 -1
- package/js/pages/TeacherDashboardCourseLearnersLayout/components/CourseLearnerDataGrid/index.tsx +1 -6
- package/js/settings/settings.prod.ts +0 -2
- package/js/settings/settings.test.ts +16 -2
- 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 +81 -32
- package/js/utils/OrderHelper/index.ts +46 -38
- package/js/utils/PaymentScheduleHelper/index.spec.tsx +78 -0
- package/js/utils/PaymentScheduleHelper/index.ts +30 -0
- package/js/utils/ProductHelper/index.spec.ts +322 -166
- package/js/utils/ProductHelper/index.ts +32 -0
- package/js/utils/test/factories/joanie.ts +72 -69
- package/js/widgets/Dashboard/components/DashboardItem/Contract/index.spec.tsx +2 -2
- package/js/widgets/Dashboard/components/DashboardItem/CourseEnrolling/index.tsx +8 -18
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.spec.tsx +23 -0
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +23 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +145 -34
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.tsx +175 -37
- package/js/widgets/Dashboard/components/DashboardItem/Order/CertificateItem/index.tsx +51 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/ContractItem/index.tsx +52 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemNotResumable.spec.tsx +109 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.spec.tsx +219 -5
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +111 -245
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.spec.tsx +61 -8
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +17 -7
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemSavePaymentMethod.spec.tsx +116 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +175 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentDetailsModal/_styles.scss +7 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentDetailsModal/index.tsx +127 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderPaymentRetryModal/index.tsx +216 -0
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.spec.tsx +18 -71
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateLearnerMessage/index.tsx +40 -25
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateMessage/index.tsx +28 -22
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.spec.tsx +18 -73
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrderStateTeacherMessage/index.tsx +32 -16
- package/js/widgets/Dashboard/components/DashboardItem/Order/OrganizationBlock/index.tsx +150 -0
- package/js/widgets/Dashboard/components/DashboardOrderLoader/index.tsx +32 -14
- package/js/widgets/Dashboard/components/Signature/SignatureDummy.tsx +25 -3
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/EnrollableCourseRunList.tsx +2 -6
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/index.spec.tsx +7 -14
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.spec.tsx +7 -5
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseRunItem/index.tsx +5 -7
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +242 -332
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +12 -13
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +10 -21
- package/js/widgets/SyllabusCourseRunsList/components/CourseRunEnrollment/index.joanie.spec.tsx +2 -2
- package/package.json +45 -44
- package/scss/components/_index.scss +4 -2
- package/js/components/PaymentButton/_styles.scss +0 -27
- package/js/components/SaleTunnel/GenericPaymentButton/index.tsx +0 -340
- package/js/components/SaleTunnel/SaleTunnelNotValidated/index.tsx +0 -70
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/ProductSignatureHeader/index.tsx +0 -41
- /package/js/components/{SaleTunnel/CreditCardSelector → CreditCardSelector}/_styles.scss +0 -0
|
@@ -4,6 +4,7 @@ import { IntlProvider } from 'react-intl';
|
|
|
4
4
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
5
5
|
import userEvent from '@testing-library/user-event';
|
|
6
6
|
import { CunninghamProvider } from '@openfun/cunningham-react';
|
|
7
|
+
import queryString from 'query-string';
|
|
7
8
|
import {
|
|
8
9
|
CourseStateFactory,
|
|
9
10
|
PacedCourseFactory,
|
|
@@ -17,7 +18,7 @@ import {
|
|
|
17
18
|
} from 'utils/test/factories/joanie';
|
|
18
19
|
import { SessionProvider } from 'contexts/SessionContext';
|
|
19
20
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
20
|
-
import { ProductType } from 'types/Joanie';
|
|
21
|
+
import { NOT_CANCELED_ORDER_STATES, ProductType } from 'types/Joanie';
|
|
21
22
|
import { Priority } from 'types';
|
|
22
23
|
import { setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
23
24
|
import { User } from 'types/User';
|
|
@@ -102,10 +103,18 @@ describe('PurchaseButton', () => {
|
|
|
102
103
|
it('shows cta to open sale tunnel when user is authenticated', async () => {
|
|
103
104
|
const courseCode = '00000';
|
|
104
105
|
const product = ProductFactory().one();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
const orderQueryParameters = {
|
|
107
|
+
course_code: courseCode,
|
|
108
|
+
product_id: product.id,
|
|
109
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
110
|
+
};
|
|
111
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
112
|
+
fetchMock
|
|
113
|
+
.get(url, {})
|
|
114
|
+
.get(
|
|
115
|
+
`https://joanie.endpoint/api/v1.0/courses/${courseCode}/products/${product.id}/payment-schedule/`,
|
|
116
|
+
[],
|
|
117
|
+
);
|
|
109
118
|
|
|
110
119
|
render(
|
|
111
120
|
<Wrapper client={createTestQueryClient({ user: richieUser })}>
|
|
@@ -137,10 +146,18 @@ describe('PurchaseButton', () => {
|
|
|
137
146
|
const product = ProductFactory({ remaining_order_count: null }).one();
|
|
138
147
|
fetchMock.get(`https://demo.endpoint/api/user/v1/accounts/${user.username}`, {});
|
|
139
148
|
fetchMock.get(`https://demo.endpoint/api/user/v1/preferences/${user.username}`, {});
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
149
|
+
const orderQueryParameters = {
|
|
150
|
+
course_code: courseCode,
|
|
151
|
+
product_id: product.id,
|
|
152
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
153
|
+
};
|
|
154
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
155
|
+
fetchMock
|
|
156
|
+
.get(url, {})
|
|
157
|
+
.get(
|
|
158
|
+
`https://joanie.endpoint/api/v1.0/courses/${courseCode}/products/${product.id}/payment-schedule/`,
|
|
159
|
+
[],
|
|
160
|
+
);
|
|
144
161
|
render(
|
|
145
162
|
<Wrapper client={createTestQueryClient({ user })}>
|
|
146
163
|
<PurchaseButton
|
|
@@ -170,10 +187,18 @@ describe('PurchaseButton', () => {
|
|
|
170
187
|
it('shows cta to open sale tunnel when remaining orders is undefined', async () => {
|
|
171
188
|
const courseCode = '00000';
|
|
172
189
|
const product = ProductFactory().one();
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
190
|
+
const orderQueryParameters = {
|
|
191
|
+
course_code: courseCode,
|
|
192
|
+
product_id: product.id,
|
|
193
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
194
|
+
};
|
|
195
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
196
|
+
fetchMock
|
|
197
|
+
.get(url, {})
|
|
198
|
+
.get(
|
|
199
|
+
`https://joanie.endpoint/api/v1.0/courses/${courseCode}/products/${product.id}/payment-schedule/`,
|
|
200
|
+
[],
|
|
201
|
+
);
|
|
177
202
|
delete product.remaining_order_count;
|
|
178
203
|
|
|
179
204
|
render(
|
|
@@ -205,10 +230,13 @@ describe('PurchaseButton', () => {
|
|
|
205
230
|
it('renders a disabled CTA if the product have no remaining orders', async () => {
|
|
206
231
|
const courseCode = '00000';
|
|
207
232
|
const product = ProductFactory({ remaining_order_count: 0 }).one();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
233
|
+
const orderQueryParameters = {
|
|
234
|
+
course_code: courseCode,
|
|
235
|
+
product_id: product.id,
|
|
236
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
237
|
+
};
|
|
238
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
239
|
+
fetchMock.get(url, {});
|
|
212
240
|
render(
|
|
213
241
|
<Wrapper client={createTestQueryClient({ user: richieUser })}>
|
|
214
242
|
<PurchaseButton
|
|
@@ -241,10 +269,14 @@ describe('PurchaseButton', () => {
|
|
|
241
269
|
const courseCode = '00000';
|
|
242
270
|
const product = ProductFactory({ ...productData, type: ProductType.CREDENTIAL }).one();
|
|
243
271
|
product.target_courses[0].course_runs = [];
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
272
|
+
|
|
273
|
+
const orderQueryParameters = {
|
|
274
|
+
course_code: courseCode,
|
|
275
|
+
product_id: product.id,
|
|
276
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
277
|
+
};
|
|
278
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
279
|
+
fetchMock.get(url, {});
|
|
248
280
|
|
|
249
281
|
render(
|
|
250
282
|
<Wrapper client={createTestQueryClient({ user: richieUser })}>
|
|
@@ -290,10 +322,14 @@ describe('PurchaseButton', () => {
|
|
|
290
322
|
const product = CertificateProductFactory().one();
|
|
291
323
|
const enrollment = EnrollmentFactory().one();
|
|
292
324
|
enrollment.course_run.state = CourseStateFactory(courseRunStateData).one();
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
325
|
+
|
|
326
|
+
const orderQueryParameters = {
|
|
327
|
+
enrollment_id: enrollment.id,
|
|
328
|
+
product_id: product.id,
|
|
329
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
330
|
+
};
|
|
331
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
332
|
+
fetchMock.get(url, {});
|
|
297
333
|
|
|
298
334
|
render(
|
|
299
335
|
<Wrapper client={createTestQueryClient({ user: true })}>
|
|
@@ -344,10 +380,13 @@ describe('PurchaseButton', () => {
|
|
|
344
380
|
const enrollment = EnrollmentFactory().one();
|
|
345
381
|
enrollment.course_run.state = CourseStateFactory(courseRunStateData).one();
|
|
346
382
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
383
|
+
const orderQueryParameters = {
|
|
384
|
+
enrollment_id: enrollment.id,
|
|
385
|
+
product_id: product.id,
|
|
386
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
387
|
+
};
|
|
388
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
389
|
+
fetchMock.get(url, {});
|
|
351
390
|
|
|
352
391
|
render(
|
|
353
392
|
<Wrapper client={createTestQueryClient({ user: true })}>
|
|
@@ -373,10 +412,14 @@ describe('PurchaseButton', () => {
|
|
|
373
412
|
it('renders a disabled CTA if product has no target courses', async () => {
|
|
374
413
|
const courseCode = '00000';
|
|
375
414
|
const product = ProductFactory().one();
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
415
|
+
|
|
416
|
+
const orderQueryParameters = {
|
|
417
|
+
course_code: courseCode,
|
|
418
|
+
product_id: product.id,
|
|
419
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
420
|
+
};
|
|
421
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
422
|
+
fetchMock.get(url, {});
|
|
380
423
|
product.target_courses = [];
|
|
381
424
|
|
|
382
425
|
render(
|
|
@@ -404,10 +447,14 @@ describe('PurchaseButton', () => {
|
|
|
404
447
|
it('does not render CTA if disabled property is false', async () => {
|
|
405
448
|
const courseCode = '00000';
|
|
406
449
|
const product = ProductFactory().one();
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
450
|
+
|
|
451
|
+
const orderQueryParameters = {
|
|
452
|
+
course_code: courseCode,
|
|
453
|
+
product_id: product.id,
|
|
454
|
+
state: NOT_CANCELED_ORDER_STATES,
|
|
455
|
+
};
|
|
456
|
+
const url = `https://joanie.endpoint/api/v1.0/orders/?${queryString.stringify(orderQueryParameters)}`;
|
|
457
|
+
fetchMock.get(url, {});
|
|
411
458
|
|
|
412
459
|
render(
|
|
413
460
|
<Wrapper client={createTestQueryClient({ user: true })}>
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import c from 'classnames';
|
|
2
2
|
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
|
3
|
-
import { useMemo } from 'react';
|
|
4
3
|
import { Button, ButtonProps, useModal } from '@openfun/cunningham-react';
|
|
5
4
|
import { useSession } from 'contexts/SessionContext';
|
|
6
5
|
import * as Joanie from 'types/Joanie';
|
|
7
|
-
import { isOpenedCourseRunCertificate, isOpenedCourseRunCredential } from 'utils/CourseRuns';
|
|
8
6
|
import { SaleTunnel, SaleTunnelProps } from 'components/SaleTunnel';
|
|
9
|
-
import { Organization } from 'types/Joanie';
|
|
7
|
+
import { CourseLight, Organization } from 'types/Joanie';
|
|
10
8
|
import { PacedCourse } from 'types';
|
|
9
|
+
import { ProductHelper } from 'utils/ProductHelper';
|
|
11
10
|
|
|
12
11
|
const messages = defineMessages({
|
|
13
12
|
loginToPurchase: {
|
|
@@ -53,7 +52,7 @@ interface PurchaseButtonPropsBase {
|
|
|
53
52
|
|
|
54
53
|
interface CredentialPurchaseButtonProps extends PurchaseButtonPropsBase {
|
|
55
54
|
product: Joanie.CredentialProduct;
|
|
56
|
-
course: PacedCourse;
|
|
55
|
+
course: PacedCourse | CourseLight;
|
|
57
56
|
enrollment?: undefined;
|
|
58
57
|
}
|
|
59
58
|
|
|
@@ -77,26 +76,9 @@ const PurchaseButton = ({
|
|
|
77
76
|
const intl = useIntl();
|
|
78
77
|
const { user, login } = useSession();
|
|
79
78
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
throw new Error(
|
|
84
|
-
'Unable to instanciate PurchaseButton with a product CERTIFICATE without the according CourseRun.',
|
|
85
|
-
);
|
|
86
|
-
}
|
|
87
|
-
return isOpenedCourseRunCertificate(enrollment.course_run.state);
|
|
88
|
-
}
|
|
89
|
-
return (
|
|
90
|
-
product.target_courses.length > 0 &&
|
|
91
|
-
product.target_courses.every(({ course_runs }) =>
|
|
92
|
-
course_runs.some((targetCourseRun) => isOpenedCourseRunCredential(targetCourseRun.state)),
|
|
93
|
-
)
|
|
94
|
-
);
|
|
95
|
-
}, [product]);
|
|
96
|
-
|
|
97
|
-
const hasAtLeastOneRemainingOrder =
|
|
98
|
-
typeof product?.remaining_order_count !== 'number' || product.remaining_order_count > 0;
|
|
99
|
-
const isPurchasable = hasAtLeastOneRemainingOrder && hasAtLeastOneCourseRun;
|
|
79
|
+
const hasOpenedTargetCourse = ProductHelper.hasOpenedTargetCourse(product, enrollment);
|
|
80
|
+
const hasRemainingSeat = ProductHelper.hasRemainingSeats(product);
|
|
81
|
+
const isPurchasable = hasRemainingSeat && hasOpenedTargetCourse;
|
|
100
82
|
|
|
101
83
|
const saleTunnelModal = useModal({
|
|
102
84
|
isOpenDefault: false,
|
|
@@ -121,7 +103,7 @@ const PurchaseButton = ({
|
|
|
121
103
|
data-testid="PurchaseButton__cta"
|
|
122
104
|
className={c('purchase-button__cta', className)}
|
|
123
105
|
onClick={() => {
|
|
124
|
-
if (
|
|
106
|
+
if (hasOpenedTargetCourse) {
|
|
125
107
|
saleTunnelModal.open();
|
|
126
108
|
}
|
|
127
109
|
}}
|
|
@@ -136,7 +118,7 @@ const PurchaseButton = ({
|
|
|
136
118
|
>
|
|
137
119
|
{product.call_to_action}
|
|
138
120
|
</Button>
|
|
139
|
-
{!
|
|
121
|
+
{!hasOpenedTargetCourse && (
|
|
140
122
|
<p className="purchase-button__no-course-run">
|
|
141
123
|
<FormattedMessage
|
|
142
124
|
{...(product.type === Joanie.ProductType.CREDENTIAL
|
|
@@ -145,7 +127,7 @@ const PurchaseButton = ({
|
|
|
145
127
|
/>
|
|
146
128
|
</p>
|
|
147
129
|
)}
|
|
148
|
-
{
|
|
130
|
+
{hasOpenedTargetCourse && !hasRemainingSeat && (
|
|
149
131
|
<p className="purchase-button__no-course-run">
|
|
150
132
|
<FormattedMessage {...messages.noRemainingOrder} />
|
|
151
133
|
</p>
|
|
@@ -58,11 +58,11 @@ describe('AddressSelector', () => {
|
|
|
58
58
|
billingAddress,
|
|
59
59
|
setBillingAddress,
|
|
60
60
|
setCreditCard: jest.fn(),
|
|
61
|
-
|
|
62
|
-
step: SaleTunnelStep.PAYMENT,
|
|
61
|
+
step: SaleTunnelStep.IDLE,
|
|
63
62
|
registerSubmitCallback: jest.fn(),
|
|
64
63
|
unregisterSubmitCallback: jest.fn(),
|
|
65
64
|
runSubmitCallbacks: jest.fn(),
|
|
65
|
+
nextStep: jest.fn(),
|
|
66
66
|
}),
|
|
67
67
|
[billingAddress],
|
|
68
68
|
);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { SaleTunnelProps } from 'components/SaleTunnel/index';
|
|
2
2
|
import { CertificateProduct } from 'types/Joanie';
|
|
3
3
|
import { GenericSaleTunnel } from 'components/SaleTunnel/GenericSaleTunnel';
|
|
4
|
-
import { GenericPaymentButton } from 'components/SaleTunnel/GenericPaymentButton';
|
|
5
4
|
import { CertificateProductPath } from 'components/SaleTunnel/CertificateSaleTunnel/CertificateProductPath';
|
|
5
|
+
import SubscriptionButton from 'components/SaleTunnel/SubscriptionButton';
|
|
6
6
|
|
|
7
7
|
interface CertificateSaleTunnelProps extends Omit<SaleTunnelProps, 'product'> {
|
|
8
8
|
product: CertificateProduct;
|
|
@@ -23,7 +23,7 @@ const CertificatePaymentButton = ({
|
|
|
23
23
|
enrollment,
|
|
24
24
|
}: Pick<CertificateSaleTunnelProps, 'enrollment'>) => {
|
|
25
25
|
return (
|
|
26
|
-
<
|
|
26
|
+
<SubscriptionButton
|
|
27
27
|
buildOrderPayload={(payload) => {
|
|
28
28
|
return {
|
|
29
29
|
...payload,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { CredentialProduct } from 'types/Joanie';
|
|
2
2
|
import { GenericSaleTunnel } from 'components/SaleTunnel/GenericSaleTunnel';
|
|
3
3
|
import { SaleTunnelProps } from 'components/SaleTunnel/index';
|
|
4
|
-
import { GenericPaymentButton } from 'components/SaleTunnel/GenericPaymentButton';
|
|
5
4
|
import { CredentialProductPath } from 'components/SaleTunnel/CredentialSaleTunnel/CredentialProductPath';
|
|
5
|
+
import SubscriptionButton from 'components/SaleTunnel/SubscriptionButton';
|
|
6
6
|
|
|
7
7
|
interface CredentialSaleTunnelProps extends Omit<SaleTunnelProps, 'product'> {
|
|
8
8
|
product: CredentialProduct;
|
|
@@ -21,17 +21,13 @@ export const CredentialSaleTunnel = (props: CredentialSaleTunnelProps) => {
|
|
|
21
21
|
|
|
22
22
|
const CredentialPaymentButton = ({
|
|
23
23
|
course,
|
|
24
|
-
orderGroup,
|
|
25
24
|
}: Pick<CredentialSaleTunnelProps, 'course' | 'orderGroup'>) => {
|
|
26
25
|
return (
|
|
27
|
-
<
|
|
28
|
-
buildOrderPayload={(payload) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
...(orderGroup ? { order_group_id: orderGroup.id } : {}),
|
|
33
|
-
};
|
|
34
|
-
}}
|
|
26
|
+
<SubscriptionButton
|
|
27
|
+
buildOrderPayload={(payload) => ({
|
|
28
|
+
...payload,
|
|
29
|
+
course_code: course!.code,
|
|
30
|
+
})}
|
|
35
31
|
/>
|
|
36
32
|
);
|
|
37
33
|
};
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Modal, ModalSize } from '@openfun/cunningham-react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
ReactNode,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
useCallback,
|
|
10
|
+
} from 'react';
|
|
3
11
|
import { SaleTunnelSponsors } from 'components/SaleTunnel/Sponsors/SaleTunnelSponsors';
|
|
4
12
|
import { SaleTunnelProps } from 'components/SaleTunnel/index';
|
|
5
|
-
import { Address, CreditCard, Order, Product } from 'types/Joanie';
|
|
13
|
+
import { Address, CreditCard, Order, OrderState, Product } from 'types/Joanie';
|
|
6
14
|
import useProductOrder from 'hooks/useProductOrder';
|
|
7
15
|
import { SaleTunnelSuccess } from 'components/SaleTunnel/SaleTunnelSuccess';
|
|
8
16
|
import WebAnalyticsAPIHandler from 'api/web-analytics';
|
|
@@ -10,7 +18,8 @@ import { CourseProductEvent } from 'types/web-analytics';
|
|
|
10
18
|
import { useOmniscientOrders, useOrders } from 'hooks/useOrders';
|
|
11
19
|
import { SaleTunnelInformation } from 'components/SaleTunnel/SaleTunnelInformation';
|
|
12
20
|
import { useEnrollments } from 'hooks/useEnrollments';
|
|
13
|
-
import
|
|
21
|
+
import SaleTunnelSavePaymentMethod from 'components/SaleTunnel/SaleTunnelSavePaymentMethod';
|
|
22
|
+
import { LearnerContractFrame } from 'components/ContractFrame';
|
|
14
23
|
|
|
15
24
|
export interface SaleTunnelContextType {
|
|
16
25
|
props: SaleTunnelProps;
|
|
@@ -19,7 +28,6 @@ export interface SaleTunnelContextType {
|
|
|
19
28
|
webAnalyticsEventKey: string;
|
|
20
29
|
|
|
21
30
|
// internal
|
|
22
|
-
onPaymentSuccess: (validated?: boolean) => void;
|
|
23
31
|
step: SaleTunnelStep;
|
|
24
32
|
|
|
25
33
|
// meta
|
|
@@ -30,6 +38,7 @@ export interface SaleTunnelContextType {
|
|
|
30
38
|
registerSubmitCallback: (key: string, callback: () => Promise<void>) => void;
|
|
31
39
|
unregisterSubmitCallback: (key: string) => void;
|
|
32
40
|
runSubmitCallbacks: () => Promise<void>;
|
|
41
|
+
nextStep: () => void;
|
|
33
42
|
}
|
|
34
43
|
|
|
35
44
|
export const SaleTunnelContext = createContext<SaleTunnelContextType>({} as any);
|
|
@@ -45,9 +54,10 @@ export const useSaleTunnelContext = () => {
|
|
|
45
54
|
};
|
|
46
55
|
|
|
47
56
|
export enum SaleTunnelStep {
|
|
48
|
-
|
|
57
|
+
IDLE,
|
|
58
|
+
SIGN,
|
|
59
|
+
SAVE_PAYMENT,
|
|
49
60
|
SUCCESS,
|
|
50
|
-
NOT_VALIDATED,
|
|
51
61
|
}
|
|
52
62
|
|
|
53
63
|
interface GenericSaleTunnelProps extends SaleTunnelProps {
|
|
@@ -64,23 +74,37 @@ export const GenericSaleTunnel = (props: GenericSaleTunnelProps) => {
|
|
|
64
74
|
enrollmentId: props.enrollment?.id,
|
|
65
75
|
productId: props.product.id,
|
|
66
76
|
});
|
|
67
|
-
|
|
68
|
-
const {
|
|
69
|
-
methods: { refetch: refetchOmniscientOrders },
|
|
70
|
-
} = useOmniscientOrders();
|
|
71
|
-
const {
|
|
72
|
-
methods: { invalidate: invalidateOrders },
|
|
73
|
-
} = useOrders(undefined, { enabled: false });
|
|
74
|
-
const {
|
|
75
|
-
methods: { invalidate: invalidateEnrollments },
|
|
76
|
-
} = useEnrollments(undefined, { enabled: false });
|
|
77
77
|
const [billingAddress, setBillingAddress] = useState<Address>();
|
|
78
78
|
const [creditCard, setCreditCard] = useState<CreditCard>();
|
|
79
|
-
const [step, setStep] = useState<SaleTunnelStep>(SaleTunnelStep.
|
|
79
|
+
const [step, setStep] = useState<SaleTunnelStep>(SaleTunnelStep.IDLE);
|
|
80
80
|
const [submitCallbacks, setSubmitCallbacks] = useState<Map<string, () => Promise<void>>>(
|
|
81
81
|
new Map(),
|
|
82
82
|
);
|
|
83
83
|
|
|
84
|
+
const nextStep = useCallback(() => {
|
|
85
|
+
if (order)
|
|
86
|
+
switch (step) {
|
|
87
|
+
case SaleTunnelStep.IDLE:
|
|
88
|
+
if ([OrderState.TO_SIGN, OrderState.SIGNING].includes(order.state)) {
|
|
89
|
+
setStep(SaleTunnelStep.SIGN);
|
|
90
|
+
} else if (order.state === OrderState.TO_SAVE_PAYMENT_METHOD) {
|
|
91
|
+
setStep(SaleTunnelStep.SAVE_PAYMENT);
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case SaleTunnelStep.SIGN:
|
|
95
|
+
if (order.state === OrderState.TO_SAVE_PAYMENT_METHOD) {
|
|
96
|
+
setStep(SaleTunnelStep.SAVE_PAYMENT);
|
|
97
|
+
}
|
|
98
|
+
if (order.state === OrderState.COMPLETED) {
|
|
99
|
+
setStep(SaleTunnelStep.SUCCESS);
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
case SaleTunnelStep.SAVE_PAYMENT:
|
|
103
|
+
setStep(SaleTunnelStep.SUCCESS);
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
}, [order, step]);
|
|
107
|
+
|
|
84
108
|
const context: SaleTunnelContextType = useMemo(
|
|
85
109
|
() => ({
|
|
86
110
|
webAnalyticsEventKey: props.eventKey,
|
|
@@ -91,23 +115,7 @@ export const GenericSaleTunnel = (props: GenericSaleTunnelProps) => {
|
|
|
91
115
|
setBillingAddress,
|
|
92
116
|
creditCard,
|
|
93
117
|
setCreditCard,
|
|
94
|
-
|
|
95
|
-
if (validated) {
|
|
96
|
-
setStep(SaleTunnelStep.SUCCESS);
|
|
97
|
-
} else {
|
|
98
|
-
setStep(SaleTunnelStep.NOT_VALIDATED);
|
|
99
|
-
}
|
|
100
|
-
WebAnalyticsAPIHandler()?.sendCourseProductEvent(
|
|
101
|
-
CourseProductEvent.PAYMENT_SUCCEED,
|
|
102
|
-
props.eventKey,
|
|
103
|
-
);
|
|
104
|
-
// Once the user has completed the purchase, we need to refetch the orders
|
|
105
|
-
// to update the ordersQuery cache
|
|
106
|
-
invalidateOrders();
|
|
107
|
-
refetchOmniscientOrders();
|
|
108
|
-
invalidateEnrollments();
|
|
109
|
-
props.onFinish?.(order!);
|
|
110
|
-
},
|
|
118
|
+
nextStep,
|
|
111
119
|
step,
|
|
112
120
|
registerSubmitCallback: (key, callback) => {
|
|
113
121
|
setSubmitCallbacks((prev) => new Map(prev).set(key, callback));
|
|
@@ -144,13 +152,16 @@ export const GenericSaleTunnel = (props: GenericSaleTunnelProps) => {
|
|
|
144
152
|
|
|
145
153
|
export const GenericSaleTunnelInner = (props: GenericSaleTunnelProps) => {
|
|
146
154
|
const { step } = useSaleTunnelContext();
|
|
155
|
+
|
|
147
156
|
switch (step) {
|
|
148
|
-
case SaleTunnelStep.
|
|
149
|
-
return <
|
|
157
|
+
case SaleTunnelStep.IDLE:
|
|
158
|
+
return <GenericSaleTunnelInitialStep {...props} />;
|
|
159
|
+
case SaleTunnelStep.SIGN:
|
|
160
|
+
return <GenericSaleTunnelSignStep {...props} />;
|
|
161
|
+
case SaleTunnelStep.SAVE_PAYMENT:
|
|
162
|
+
return <GenericSaleTunnelSavePaymentMethodStep {...props} />;
|
|
150
163
|
case SaleTunnelStep.SUCCESS:
|
|
151
164
|
return <GenericSaleTunnelSuccessStep {...props} />;
|
|
152
|
-
case SaleTunnelStep.NOT_VALIDATED:
|
|
153
|
-
return <GenericSaleTunnelNotValidatedStep {...props} />;
|
|
154
165
|
}
|
|
155
166
|
throw new Error('Invalid step: ' + step);
|
|
156
167
|
};
|
|
@@ -159,7 +170,7 @@ export const GenericSaleTunnelInner = (props: GenericSaleTunnelProps) => {
|
|
|
159
170
|
* Steps.
|
|
160
171
|
*/
|
|
161
172
|
|
|
162
|
-
export const
|
|
173
|
+
export const GenericSaleTunnelInitialStep = (props: GenericSaleTunnelProps) => {
|
|
163
174
|
const { webAnalyticsEventKey } = useSaleTunnelContext();
|
|
164
175
|
|
|
165
176
|
useEffect(() => {
|
|
@@ -174,25 +185,55 @@ export const GenericSaleTunnelPaymentStep = (props: GenericSaleTunnelProps) => {
|
|
|
174
185
|
}, []);
|
|
175
186
|
|
|
176
187
|
return (
|
|
177
|
-
<Modal {...props} size={ModalSize.EXTRA_LARGE} title={props.product.title}
|
|
188
|
+
<Modal {...props} size={ModalSize.EXTRA_LARGE} title={props.product.title}>
|
|
178
189
|
<div className="sale-tunnel" data-testid="generic-sale-tunnel-payment-step">
|
|
179
190
|
<div className="sale-tunnel__main">
|
|
180
|
-
<div className="sale-tunnel__main__left">
|
|
191
|
+
<div className="sale-tunnel__main__column sale-tunnel__main__left ">
|
|
192
|
+
<div>{props.asideNode}</div>
|
|
193
|
+
<div>
|
|
194
|
+
<SaleTunnelSponsors />
|
|
195
|
+
</div>
|
|
196
|
+
</div>
|
|
181
197
|
<div className="sale-tunnel__main__separator" />
|
|
182
198
|
<div className="sale-tunnel__main__right">
|
|
183
199
|
<SaleTunnelInformation />
|
|
184
200
|
</div>
|
|
185
201
|
</div>
|
|
186
|
-
<div className="sale-tunnel__footer">
|
|
187
|
-
{props.paymentNode}
|
|
188
|
-
<SaleTunnelSponsors />
|
|
189
|
-
</div>
|
|
202
|
+
<div className="sale-tunnel__footer">{props.paymentNode}</div>
|
|
190
203
|
</div>
|
|
191
204
|
</Modal>
|
|
192
205
|
);
|
|
193
206
|
};
|
|
194
207
|
|
|
195
208
|
export const GenericSaleTunnelSuccessStep = (props: SaleTunnelProps) => {
|
|
209
|
+
const {
|
|
210
|
+
webAnalyticsEventKey,
|
|
211
|
+
props: { onFinish },
|
|
212
|
+
order,
|
|
213
|
+
} = useSaleTunnelContext();
|
|
214
|
+
const {
|
|
215
|
+
methods: { refetch: refetchOmniscientOrders },
|
|
216
|
+
} = useOmniscientOrders();
|
|
217
|
+
const {
|
|
218
|
+
methods: { invalidate: invalidateOrders },
|
|
219
|
+
} = useOrders(undefined, { enabled: false });
|
|
220
|
+
const {
|
|
221
|
+
methods: { invalidate: invalidateEnrollments },
|
|
222
|
+
} = useEnrollments(undefined, { enabled: false });
|
|
223
|
+
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
WebAnalyticsAPIHandler()?.sendCourseProductEvent(
|
|
226
|
+
CourseProductEvent.PAYMENT_SUCCEED,
|
|
227
|
+
webAnalyticsEventKey,
|
|
228
|
+
);
|
|
229
|
+
// Once the user has completed the purchase, we need to refetch the orders
|
|
230
|
+
// to update the ordersQuery cache
|
|
231
|
+
invalidateOrders();
|
|
232
|
+
refetchOmniscientOrders();
|
|
233
|
+
invalidateEnrollments();
|
|
234
|
+
onFinish?.(order!);
|
|
235
|
+
}, []);
|
|
236
|
+
|
|
196
237
|
return (
|
|
197
238
|
<Modal {...props} size={ModalSize.MEDIUM}>
|
|
198
239
|
<SaleTunnelSuccess closeModal={props.onClose} />
|
|
@@ -200,10 +241,26 @@ export const GenericSaleTunnelSuccessStep = (props: SaleTunnelProps) => {
|
|
|
200
241
|
);
|
|
201
242
|
};
|
|
202
243
|
|
|
203
|
-
export const
|
|
244
|
+
export const GenericSaleTunnelSavePaymentMethodStep = (props: SaleTunnelProps) => {
|
|
204
245
|
return (
|
|
205
|
-
<Modal {...props} size={ModalSize.
|
|
206
|
-
<
|
|
246
|
+
<Modal {...props} size={ModalSize.LARGE}>
|
|
247
|
+
<SaleTunnelSavePaymentMethod />
|
|
207
248
|
</Modal>
|
|
208
249
|
);
|
|
209
250
|
};
|
|
251
|
+
|
|
252
|
+
export const GenericSaleTunnelSignStep = ({ isOpen, onClose }: SaleTunnelProps) => {
|
|
253
|
+
const { order, nextStep } = useSaleTunnelContext();
|
|
254
|
+
|
|
255
|
+
const handleDone = useCallback(nextStep, [order]);
|
|
256
|
+
|
|
257
|
+
useEffect(() => {
|
|
258
|
+
if (![OrderState.TO_SIGN, OrderState.SIGNING].includes(order!.state)) {
|
|
259
|
+
nextStep();
|
|
260
|
+
}
|
|
261
|
+
}, [order]);
|
|
262
|
+
|
|
263
|
+
return (
|
|
264
|
+
<LearnerContractFrame order={order!} isOpen={isOpen} onClose={onClose} onDone={handleDone} />
|
|
265
|
+
);
|
|
266
|
+
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Alert, VariantType } from '@openfun/cunningham-react';
|
|
2
1
|
import { defineMessages, FormattedMessage, FormattedNumber } from 'react-intl';
|
|
3
2
|
import { AddressSelector } from 'components/SaleTunnel/AddressSelector';
|
|
4
|
-
import { CreditCardSelector } from 'components/SaleTunnel/CreditCardSelector';
|
|
5
3
|
import { PaymentScheduleGrid } from 'components/PaymentScheduleGrid';
|
|
6
4
|
import { useSaleTunnelContext } from 'components/SaleTunnel/GenericSaleTunnel';
|
|
7
5
|
import OpenEdxFullNameForm from 'components/OpenEdxFullNameForm';
|
|
8
6
|
import { useSession } from 'contexts/SessionContext';
|
|
9
7
|
import useOpenEdxProfile from 'hooks/useOpenEdxProfile';
|
|
8
|
+
import { usePaymentSchedule } from 'hooks/usePaymentSchedule';
|
|
9
|
+
import { Spinner } from 'components/Spinner';
|
|
10
10
|
|
|
11
11
|
const messages = defineMessages({
|
|
12
12
|
title: {
|
|
@@ -49,7 +49,7 @@ const messages = defineMessages({
|
|
|
49
49
|
|
|
50
50
|
export const SaleTunnelInformation = () => {
|
|
51
51
|
return (
|
|
52
|
-
<div className="sale-tunnel__information">
|
|
52
|
+
<div className="sale-tunnel__main__column sale-tunnel__information">
|
|
53
53
|
<div>
|
|
54
54
|
<h3 className="block-title mb-t">
|
|
55
55
|
<FormattedMessage {...messages.title} />
|
|
@@ -64,15 +64,12 @@ export const SaleTunnelInformation = () => {
|
|
|
64
64
|
</div>
|
|
65
65
|
</div>
|
|
66
66
|
<div>
|
|
67
|
-
<
|
|
68
|
-
</div>
|
|
69
|
-
<div>
|
|
67
|
+
<PaymentScheduleBlock />
|
|
70
68
|
<Total />
|
|
71
69
|
</div>
|
|
72
70
|
</div>
|
|
73
71
|
);
|
|
74
72
|
};
|
|
75
|
-
|
|
76
73
|
const Email = () => {
|
|
77
74
|
const { user } = useSession();
|
|
78
75
|
const { data: openEdxProfileData } = useOpenEdxProfile({
|
|
@@ -98,9 +95,6 @@ const Total = () => {
|
|
|
98
95
|
const { product } = useSaleTunnelContext();
|
|
99
96
|
return (
|
|
100
97
|
<div className="sale-tunnel__total">
|
|
101
|
-
<Alert type={VariantType.INFO}>
|
|
102
|
-
<FormattedMessage {...messages.totalInfo} />
|
|
103
|
-
</Alert>
|
|
104
98
|
<div className="sale-tunnel__total__amount mt-t" data-testid="sale-tunnel__total__amount">
|
|
105
99
|
<div className="block-title">
|
|
106
100
|
<FormattedMessage {...messages.totalLabel} />
|
|
@@ -117,20 +111,22 @@ const Total = () => {
|
|
|
117
111
|
);
|
|
118
112
|
};
|
|
119
113
|
|
|
120
|
-
/**
|
|
121
|
-
* Ready for V2.
|
|
122
|
-
*/
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
124
114
|
const PaymentScheduleBlock = () => {
|
|
125
|
-
|
|
115
|
+
const { props } = useSaleTunnelContext();
|
|
116
|
+
const query = usePaymentSchedule({
|
|
117
|
+
course_code: props.course?.code || props.enrollment!.course_run.course.code,
|
|
118
|
+
product_id: props.product.id,
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
if (!query.data || query.isLoading) {
|
|
122
|
+
return <Spinner size="large" />;
|
|
123
|
+
}
|
|
124
|
+
|
|
126
125
|
return (
|
|
127
126
|
<div className="payment-schedule">
|
|
128
|
-
<h4 className="block-title mb-t">
|
|
129
|
-
<Alert type={VariantType.INFO}>
|
|
130
|
-
The first payment occurs in 14 days, you will be notified to pay the first 30%.
|
|
131
|
-
</Alert>
|
|
127
|
+
<h4 className="block-title mb-t">Payment schedule</h4>
|
|
132
128
|
<div className="mt-t">
|
|
133
|
-
<PaymentScheduleGrid />
|
|
129
|
+
<PaymentScheduleGrid schedule={query.data} />
|
|
134
130
|
</div>
|
|
135
131
|
</div>
|
|
136
132
|
);
|