richie-education 3.1.3-dev2 → 3.1.3-dev24
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/.storybook/__mocks__/utils/context.ts +4 -0
- package/js/api/joanie.ts +8 -8
- package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +11 -19
- package/js/components/ContractFrame/OrganizationContractFrame.tsx +4 -4
- package/js/components/CourseGlimpse/index.spec.tsx +2 -0
- package/js/components/CourseGlimpse/index.tsx +2 -0
- package/js/components/CourseGlimpse/utils.ts +29 -30
- package/js/components/CourseGlimpseList/utils.ts +2 -2
- package/js/components/PurchaseButton/index.tsx +3 -3
- package/js/components/SaleTunnel/CredentialSaleTunnel/index.tsx +1 -3
- package/js/components/SaleTunnel/GenericSaleTunnel.tsx +13 -1
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +9 -7
- package/js/components/SaleTunnel/SubscriptionButton/index.tsx +1 -2
- package/js/components/SaleTunnel/index.credential.spec.tsx +5 -19
- package/js/components/SaleTunnel/index.full-process.spec.tsx +3 -3
- package/js/components/SaleTunnel/index.spec.tsx +171 -29
- package/js/components/SaleTunnel/index.stories.tsx +17 -3
- package/js/components/SaleTunnel/index.tsx +2 -2
- package/js/components/TeacherDashboardCourseList/index.spec.tsx +3 -3
- package/js/components/TeacherDashboardCourseList/index.tsx +2 -2
- package/js/hooks/useContractArchive/index.ts +3 -3
- package/js/hooks/useCourseProductUnion/index.spec.tsx +16 -18
- package/js/hooks/useCourseProductUnion/index.ts +7 -7
- package/js/hooks/useCourseProducts.ts +4 -8
- package/js/hooks/useDefaultOrganizationId/index.tsx +4 -7
- package/js/hooks/useOffering/index.ts +32 -0
- package/js/hooks/useTeacherCoursesSearch/index.tsx +2 -2
- package/js/hooks/useTeacherPendingContractsCount/index.ts +4 -4
- package/js/pages/DashboardCourses/index.spec.tsx +14 -14
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +11 -14
- package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +4 -9
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +10 -13
- package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +20 -28
- package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +8 -11
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +6 -6
- package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +7 -7
- package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +5 -5
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +21 -28
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +13 -17
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +11 -13
- package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +6 -6
- package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +3 -3
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +16 -16
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +4 -4
- package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +4 -4
- package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx +21 -21
- package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.ts +5 -10
- package/js/pages/TeacherDashboardCourseLearnersLayout/index.spec.tsx +61 -79
- package/js/pages/TeacherDashboardCourseLearnersLayout/index.tsx +1 -1
- package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +11 -11
- package/js/pages/TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx +7 -7
- package/js/pages/TeacherDashboardTraining/index.spec.tsx +21 -29
- package/js/pages/TeacherDashboardTraining/index.tsx +12 -16
- package/js/types/Course.ts +2 -0
- package/js/types/Joanie.ts +34 -29
- package/js/types/index.ts +4 -2
- package/js/utils/ProductHelper/index.ts +1 -5
- package/js/utils/test/factories/joanie.ts +17 -25
- package/js/utils/test/factories/richie.ts +6 -2
- package/js/utils/test/mockCourseProductWithOrder.ts +4 -4
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +3 -3
- package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +1 -1
- package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +4 -4
- package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +1 -1
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +23 -28
- package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +4 -8
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +17 -24
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +18 -21
- package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +4 -4
- package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +3 -7
- package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +4 -4
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +19 -34
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/_styles.scss +34 -8
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/CourseRunList.tsx +3 -3
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/_styles.scss +9 -0
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +186 -140
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +11 -2
- package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +111 -24
- package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +8 -8
- package/package.json +1 -1
- package/js/hooks/useCourseProductRelation/index.ts +0 -44
package/js/api/joanie.ts
CHANGED
|
@@ -127,8 +127,8 @@ export const getRoutes = () => {
|
|
|
127
127
|
},
|
|
128
128
|
organizations: {
|
|
129
129
|
get: `${baseUrl}/organizations/:id/`,
|
|
130
|
-
|
|
131
|
-
get: `${baseUrl}/organizations/:organization_id/
|
|
130
|
+
offerings: {
|
|
131
|
+
get: `${baseUrl}/organizations/:organization_id/offerings/:id/`,
|
|
132
132
|
},
|
|
133
133
|
courses: {
|
|
134
134
|
get: `${baseUrl}/organizations/:organization_id/courses/:id/`,
|
|
@@ -156,8 +156,8 @@ export const getRoutes = () => {
|
|
|
156
156
|
courseRuns: {
|
|
157
157
|
get: `${baseUrl}/course-runs/:id/`,
|
|
158
158
|
},
|
|
159
|
-
|
|
160
|
-
get: `${baseUrl}/
|
|
159
|
+
offerings: {
|
|
160
|
+
get: `${baseUrl}/offerings/:id/`,
|
|
161
161
|
},
|
|
162
162
|
contractDefinitions: {
|
|
163
163
|
previewTemplate: `${baseUrl}/contract_definitions/:id/preview_template/`,
|
|
@@ -470,12 +470,12 @@ const API = (): Joanie.API => {
|
|
|
470
470
|
).then(checkStatus);
|
|
471
471
|
},
|
|
472
472
|
},
|
|
473
|
-
|
|
474
|
-
get: (filters?: Joanie.
|
|
473
|
+
offerings: {
|
|
474
|
+
get: (filters?: Joanie.OfferingQueryFilters) => {
|
|
475
475
|
return fetchWithJWT(
|
|
476
476
|
filters?.organization_id
|
|
477
|
-
? buildApiUrl(ROUTES.organizations.
|
|
478
|
-
: buildApiUrl(ROUTES.
|
|
477
|
+
? buildApiUrl(ROUTES.organizations.offerings.get, filters)
|
|
478
|
+
: buildApiUrl(ROUTES.offerings.get, filters),
|
|
479
479
|
).then(checkStatus);
|
|
480
480
|
},
|
|
481
481
|
},
|
|
@@ -6,14 +6,10 @@ import { IntlProvider } from 'react-intl';
|
|
|
6
6
|
import fetchMock from 'fetch-mock';
|
|
7
7
|
import { QueryStateFactory } from 'utils/test/factories/reactQuery';
|
|
8
8
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
9
|
-
import {
|
|
10
|
-
ContractFactory,
|
|
11
|
-
CourseProductRelationFactory,
|
|
12
|
-
OrganizationFactory,
|
|
13
|
-
} from 'utils/test/factories/joanie';
|
|
9
|
+
import { ContractFactory, OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
|
|
14
10
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
15
11
|
import JoanieSessionProvider from 'contexts/SessionContext/JoanieSessionProvider';
|
|
16
|
-
import {
|
|
12
|
+
import { isOffering } from 'types/Joanie';
|
|
17
13
|
import { Props } from './AbstractContractFrame';
|
|
18
14
|
import { OrganizationContractFrame } from '.';
|
|
19
15
|
|
|
@@ -77,31 +73,29 @@ describe('OrganizationContractFrame', () => {
|
|
|
77
73
|
|
|
78
74
|
it.each([
|
|
79
75
|
{
|
|
80
|
-
label: 'contractList: undefined,
|
|
76
|
+
label: 'contractList: undefined, offering: undefined',
|
|
81
77
|
contractList: undefined,
|
|
82
|
-
|
|
78
|
+
offering: undefined,
|
|
83
79
|
},
|
|
84
80
|
{
|
|
85
|
-
label: 'contractList: 2 Contract,
|
|
81
|
+
label: 'contractList: 2 Contract, offering: undefined',
|
|
86
82
|
contractList: ContractFactory().many(2),
|
|
87
|
-
|
|
83
|
+
offering: undefined,
|
|
88
84
|
},
|
|
89
85
|
{
|
|
90
|
-
label: 'contractList: undefined,
|
|
86
|
+
label: 'contractList: undefined, offering: one Offering',
|
|
91
87
|
contractList: undefined,
|
|
92
|
-
|
|
88
|
+
offering: OfferingFactory().one(),
|
|
93
89
|
},
|
|
94
90
|
])(
|
|
95
91
|
'should implement AbstractContractFrame for organization and $label',
|
|
96
|
-
async ({ contractList,
|
|
92
|
+
async ({ contractList, offering }) => {
|
|
97
93
|
const organization = OrganizationFactory().one();
|
|
98
94
|
const contracts = contractList || ContractFactory().many(2);
|
|
99
95
|
const isOpen = faker.datatype.boolean();
|
|
100
96
|
|
|
101
97
|
const invitationLinkQueryString =
|
|
102
|
-
|
|
103
|
-
? `?course_product_relation_ids=${courseProductRelation.id}`
|
|
104
|
-
: '';
|
|
98
|
+
offering && isOffering(offering) ? `?offering_ids=${offering.id}` : '';
|
|
105
99
|
const expectedUrls = {
|
|
106
100
|
getInvitationLink: `https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts-signature-link/${invitationLinkQueryString}`,
|
|
107
101
|
checkSignature: `https://joanie.endpoint/api/v1.0/organizations/${organization.id}/contracts/?id=${contracts[0].id}&id=${contracts[1].id}`,
|
|
@@ -133,9 +127,7 @@ describe('OrganizationContractFrame', () => {
|
|
|
133
127
|
<Wrapper client={client}>
|
|
134
128
|
<OrganizationContractFrame
|
|
135
129
|
organizationId={organization.id}
|
|
136
|
-
|
|
137
|
-
courseProductRelation ? [courseProductRelation.id] : undefined
|
|
138
|
-
}
|
|
130
|
+
offeringIds={offering ? [offering.id] : undefined}
|
|
139
131
|
isOpen={isOpen}
|
|
140
132
|
onDone={handleDone}
|
|
141
133
|
onClose={handleClose}
|
|
@@ -4,17 +4,17 @@ import { useJoanieApi } from 'contexts/JoanieApiContext';
|
|
|
4
4
|
import AbstractContractFrame, {
|
|
5
5
|
AbstractProps,
|
|
6
6
|
} from 'components/ContractFrame/AbstractContractFrame';
|
|
7
|
-
import { Contract,
|
|
7
|
+
import { Contract, Offering } from 'types/Joanie';
|
|
8
8
|
|
|
9
9
|
interface Props extends AbstractProps {
|
|
10
10
|
contractIds?: Contract['id'][];
|
|
11
11
|
organizationId: string;
|
|
12
|
-
|
|
12
|
+
offeringIds?: Offering['id'][];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
const OrganizationContractFrame = ({
|
|
16
16
|
organizationId,
|
|
17
|
-
|
|
17
|
+
offeringIds = [],
|
|
18
18
|
contractIds,
|
|
19
19
|
onDone,
|
|
20
20
|
...props
|
|
@@ -29,7 +29,7 @@ const OrganizationContractFrame = ({
|
|
|
29
29
|
be signed. We need to keep track of these ids to check if all contracts have been signed.
|
|
30
30
|
*/
|
|
31
31
|
const response = await api.organizations.contracts.getSignatureLinks({
|
|
32
|
-
|
|
32
|
+
offering_ids: offeringIds,
|
|
33
33
|
organization_id: organizationId,
|
|
34
34
|
contracts_ids: contractIds,
|
|
35
35
|
});
|
|
@@ -59,6 +59,8 @@ describe('widgets/Search/components/CourseGlimpse', () => {
|
|
|
59
59
|
certificate_offer: CourseCertificateOffer.FREE,
|
|
60
60
|
certificate_price: null,
|
|
61
61
|
price_currency: 'EUR',
|
|
62
|
+
discounted_price: null,
|
|
63
|
+
discount: null,
|
|
62
64
|
};
|
|
63
65
|
|
|
64
66
|
const contextProps: CommonDataProps['context'] = RichieContextFactory().one();
|
|
@@ -8,21 +8,21 @@ import {
|
|
|
8
8
|
} from 'types/Course';
|
|
9
9
|
import {
|
|
10
10
|
CourseListItem as JoanieCourse,
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
OfferingLight,
|
|
12
|
+
isOffering,
|
|
13
13
|
ProductType,
|
|
14
14
|
} from 'types/Joanie';
|
|
15
15
|
import { TeacherDashboardPaths } from 'widgets/Dashboard/utils/teacherDashboardPaths';
|
|
16
16
|
import { CourseGlimpseCourse } from '.';
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
18
|
+
const getCourseGlimpsePropsFromOffering = (
|
|
19
|
+
offering: OfferingLight,
|
|
20
20
|
intl: IntlShape,
|
|
21
21
|
organizationId?: string,
|
|
22
22
|
): CourseGlimpseCourse => {
|
|
23
23
|
const courseRouteParams = {
|
|
24
|
-
courseId:
|
|
25
|
-
|
|
24
|
+
courseId: offering.course.id,
|
|
25
|
+
offeringId: offering.id,
|
|
26
26
|
};
|
|
27
27
|
const courseRoute = organizationId
|
|
28
28
|
? generatePath(TeacherDashboardPaths.ORGANIZATION_PRODUCT, {
|
|
@@ -31,35 +31,30 @@ const getCourseGlimpsePropsFromCourseProductRelation = (
|
|
|
31
31
|
})
|
|
32
32
|
: generatePath(TeacherDashboardPaths.COURSE_PRODUCT, courseRouteParams);
|
|
33
33
|
return {
|
|
34
|
-
id:
|
|
35
|
-
code:
|
|
36
|
-
title:
|
|
37
|
-
cover_image:
|
|
34
|
+
id: offering.id,
|
|
35
|
+
code: offering.course.code,
|
|
36
|
+
title: offering.product.title,
|
|
37
|
+
cover_image: offering.course.cover
|
|
38
38
|
? {
|
|
39
|
-
src:
|
|
39
|
+
src: offering.course.cover.src,
|
|
40
40
|
}
|
|
41
41
|
: null,
|
|
42
42
|
organization: {
|
|
43
|
-
title:
|
|
44
|
-
image:
|
|
43
|
+
title: offering.organizations[0].title,
|
|
44
|
+
image: offering.organizations[0].logo || null,
|
|
45
45
|
},
|
|
46
|
-
product_id:
|
|
46
|
+
product_id: offering.product.id,
|
|
47
47
|
course_route: courseRoute,
|
|
48
|
-
state:
|
|
48
|
+
state: offering.product.state,
|
|
49
49
|
certificate_offer:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
: null,
|
|
53
|
-
offer: courseProductRelation.product.type === ProductType.CREDENTIAL ? CourseOffer.PAID : null,
|
|
50
|
+
offering.product.type === ProductType.CERTIFICATE ? CourseCertificateOffer.PAID : null,
|
|
51
|
+
offer: offering.product.type === ProductType.CREDENTIAL ? CourseOffer.PAID : null,
|
|
54
52
|
certificate_price:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
? courseProductRelation.product.price
|
|
61
|
-
: null,
|
|
62
|
-
price_currency: courseProductRelation.product.price_currency,
|
|
53
|
+
offering.product.type === ProductType.CERTIFICATE ? offering.product.price : null,
|
|
54
|
+
price: offering.product.type === ProductType.CREDENTIAL ? offering.product.price : null,
|
|
55
|
+
price_currency: offering.product.price_currency,
|
|
56
|
+
discounted_price: offering.product.discounted_price || null,
|
|
57
|
+
discount: offering.product.discount || null,
|
|
63
58
|
};
|
|
64
59
|
};
|
|
65
60
|
|
|
@@ -84,6 +79,8 @@ const getCourseGlimpsePropsFromRichieCourse = (course: RichieCourse): CourseGlim
|
|
|
84
79
|
certificate_offer: course.certificate_offer,
|
|
85
80
|
offer: course.offer,
|
|
86
81
|
certificate_price: course.certificate_price,
|
|
82
|
+
discounted_price: course.discounted_price,
|
|
83
|
+
discount: course.discount,
|
|
87
84
|
});
|
|
88
85
|
|
|
89
86
|
const getCourseGlimpsePropsFromJoanieCourse = (
|
|
@@ -121,16 +118,18 @@ const getCourseGlimpsePropsFromJoanieCourse = (
|
|
|
121
118
|
certificate_offer: null,
|
|
122
119
|
offer: null,
|
|
123
120
|
certificate_price: null,
|
|
121
|
+
discounted_price: null,
|
|
122
|
+
discount: null,
|
|
124
123
|
};
|
|
125
124
|
};
|
|
126
125
|
|
|
127
126
|
export const getCourseGlimpseProps = (
|
|
128
|
-
course: RichieCourse | (JoanieCourse |
|
|
127
|
+
course: RichieCourse | (JoanieCourse | OfferingLight),
|
|
129
128
|
intl?: IntlShape,
|
|
130
129
|
organizationId?: string,
|
|
131
130
|
): CourseGlimpseCourse => {
|
|
132
|
-
if (
|
|
133
|
-
return
|
|
131
|
+
if (isOffering(course)) {
|
|
132
|
+
return getCourseGlimpsePropsFromOffering(course, intl!, organizationId);
|
|
134
133
|
}
|
|
135
134
|
|
|
136
135
|
if (isRichieCourse(course)) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { IntlShape } from 'react-intl';
|
|
2
|
-
import {
|
|
2
|
+
import { OfferingLight, CourseListItem as JoanieCourse } from 'types/Joanie';
|
|
3
3
|
import { Course as RichieCourse } from 'types/Course';
|
|
4
4
|
import { CourseGlimpseCourse, getCourseGlimpseProps } from 'components/CourseGlimpse';
|
|
5
5
|
|
|
6
6
|
export const getCourseGlimpseListProps = (
|
|
7
|
-
courses: RichieCourse[] | (JoanieCourse |
|
|
7
|
+
courses: RichieCourse[] | (JoanieCourse | OfferingLight)[],
|
|
8
8
|
intl?: IntlShape,
|
|
9
9
|
organizationId?: string,
|
|
10
10
|
): CourseGlimpseCourse[] => {
|
|
@@ -42,7 +42,7 @@ const messages = defineMessages({
|
|
|
42
42
|
|
|
43
43
|
interface PurchaseButtonPropsBase {
|
|
44
44
|
product: Joanie.CredentialProduct | Joanie.CertificateProduct;
|
|
45
|
-
|
|
45
|
+
offering?: Joanie.Offering;
|
|
46
46
|
isWithdrawable: boolean;
|
|
47
47
|
disabled?: boolean;
|
|
48
48
|
className?: string;
|
|
@@ -66,8 +66,8 @@ interface CertificatePurchaseButtonProps extends PurchaseButtonPropsBase {
|
|
|
66
66
|
const PurchaseButton = ({
|
|
67
67
|
product,
|
|
68
68
|
course,
|
|
69
|
+
offering,
|
|
69
70
|
enrollment,
|
|
70
|
-
orderGroup,
|
|
71
71
|
isWithdrawable,
|
|
72
72
|
organizations,
|
|
73
73
|
disabled = false,
|
|
@@ -140,8 +140,8 @@ const PurchaseButton = ({
|
|
|
140
140
|
{...saleTunnelModal}
|
|
141
141
|
product={product}
|
|
142
142
|
organizations={organizations}
|
|
143
|
+
offering={offering}
|
|
143
144
|
enrollment={enrollment}
|
|
144
|
-
orderGroup={orderGroup}
|
|
145
145
|
course={course}
|
|
146
146
|
isWithdrawable={isWithdrawable}
|
|
147
147
|
onFinish={onFinish}
|
|
@@ -19,9 +19,7 @@ export const CredentialSaleTunnel = (props: CredentialSaleTunnelProps) => {
|
|
|
19
19
|
);
|
|
20
20
|
};
|
|
21
21
|
|
|
22
|
-
const CredentialPaymentButton = ({
|
|
23
|
-
course,
|
|
24
|
-
}: Pick<CredentialSaleTunnelProps, 'course' | 'orderGroup'>) => {
|
|
22
|
+
const CredentialPaymentButton = ({ course }: Pick<CredentialSaleTunnelProps, 'course'>) => {
|
|
25
23
|
return (
|
|
26
24
|
<SubscriptionButton
|
|
27
25
|
buildOrderPayload={(payload) => ({
|
|
@@ -10,7 +10,15 @@ import {
|
|
|
10
10
|
} from 'react';
|
|
11
11
|
import { SaleTunnelSponsors } from 'components/SaleTunnel/Sponsors/SaleTunnelSponsors';
|
|
12
12
|
import { SaleTunnelProps } from 'components/SaleTunnel/index';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
Address,
|
|
15
|
+
Enrollment,
|
|
16
|
+
Offering,
|
|
17
|
+
CreditCard,
|
|
18
|
+
Order,
|
|
19
|
+
OrderState,
|
|
20
|
+
Product,
|
|
21
|
+
} from 'types/Joanie';
|
|
14
22
|
import useProductOrder from 'hooks/useProductOrder';
|
|
15
23
|
import { SaleTunnelSuccess } from 'components/SaleTunnel/SaleTunnelSuccess';
|
|
16
24
|
import WebAnalyticsAPIHandler from 'api/web-analytics';
|
|
@@ -26,6 +34,8 @@ export interface SaleTunnelContextType {
|
|
|
26
34
|
order?: Order;
|
|
27
35
|
product: Product;
|
|
28
36
|
webAnalyticsEventKey: string;
|
|
37
|
+
offering?: Offering;
|
|
38
|
+
enrollment?: Enrollment;
|
|
29
39
|
|
|
30
40
|
// internal
|
|
31
41
|
step: SaleTunnelStep;
|
|
@@ -113,6 +123,8 @@ export const GenericSaleTunnel = (props: GenericSaleTunnelProps) => {
|
|
|
113
123
|
webAnalyticsEventKey: props.eventKey,
|
|
114
124
|
order,
|
|
115
125
|
product: props.product,
|
|
126
|
+
offering: props.offering,
|
|
127
|
+
enrollment: props.enrollment,
|
|
116
128
|
props,
|
|
117
129
|
billingAddress,
|
|
118
130
|
setBillingAddress,
|
|
@@ -8,6 +8,7 @@ import useOpenEdxProfile from 'hooks/useOpenEdxProfile';
|
|
|
8
8
|
import { usePaymentSchedule } from 'hooks/usePaymentSchedule';
|
|
9
9
|
import { Spinner } from 'components/Spinner';
|
|
10
10
|
import WithdrawRightCheckbox from 'components/SaleTunnel/WithdrawRightCheckbox';
|
|
11
|
+
import { ProductType } from 'types/Joanie';
|
|
11
12
|
|
|
12
13
|
const messages = defineMessages({
|
|
13
14
|
title: {
|
|
@@ -54,6 +55,7 @@ const messages = defineMessages({
|
|
|
54
55
|
});
|
|
55
56
|
|
|
56
57
|
export const SaleTunnelInformation = () => {
|
|
58
|
+
const { product } = useSaleTunnelContext();
|
|
57
59
|
return (
|
|
58
60
|
<div className="sale-tunnel__main__column sale-tunnel__information">
|
|
59
61
|
<div>
|
|
@@ -70,7 +72,7 @@ export const SaleTunnelInformation = () => {
|
|
|
70
72
|
</div>
|
|
71
73
|
</div>
|
|
72
74
|
<div>
|
|
73
|
-
<PaymentScheduleBlock />
|
|
75
|
+
{product.type === ProductType.CREDENTIAL && <PaymentScheduleBlock />}
|
|
74
76
|
<Total />
|
|
75
77
|
<WithdrawRightCheckbox />
|
|
76
78
|
</div>
|
|
@@ -99,7 +101,11 @@ const Email = () => {
|
|
|
99
101
|
};
|
|
100
102
|
|
|
101
103
|
const Total = () => {
|
|
102
|
-
const { product } = useSaleTunnelContext();
|
|
104
|
+
const { product, offering, enrollment } = useSaleTunnelContext();
|
|
105
|
+
const totalPrice =
|
|
106
|
+
enrollment?.offerings?.[0]?.rules?.discounted_price ??
|
|
107
|
+
offering?.rules.discounted_price ??
|
|
108
|
+
product.price;
|
|
103
109
|
return (
|
|
104
110
|
<div className="sale-tunnel__total">
|
|
105
111
|
<div className="sale-tunnel__total__amount mt-t" data-testid="sale-tunnel__total__amount">
|
|
@@ -107,11 +113,7 @@ const Total = () => {
|
|
|
107
113
|
<FormattedMessage {...messages.totalLabel} />
|
|
108
114
|
</div>
|
|
109
115
|
<div className="block-title">
|
|
110
|
-
<FormattedNumber
|
|
111
|
-
value={product.price}
|
|
112
|
-
style="currency"
|
|
113
|
-
currency={product.price_currency}
|
|
114
|
-
/>
|
|
116
|
+
<FormattedNumber value={totalPrice} style="currency" currency={product.price_currency} />
|
|
115
117
|
</div>
|
|
116
118
|
</div>
|
|
117
119
|
</div>
|
|
@@ -72,7 +72,7 @@ interface Props {
|
|
|
72
72
|
buildOrderPayload: (
|
|
73
73
|
payload: Pick<
|
|
74
74
|
OrderCreationPayload,
|
|
75
|
-
'product_id' | 'billing_address' | '
|
|
75
|
+
'product_id' | 'billing_address' | 'has_waived_withdrawal_right'
|
|
76
76
|
>,
|
|
77
77
|
) => OrderCreationPayload;
|
|
78
78
|
}
|
|
@@ -124,7 +124,6 @@ const SubscriptionButton = ({ buildOrderPayload }: Props) => {
|
|
|
124
124
|
const payload = buildOrderPayload({
|
|
125
125
|
product_id: product.id,
|
|
126
126
|
billing_address: billingAddress!,
|
|
127
|
-
order_group_id: saleTunnelProps.orderGroup?.id,
|
|
128
127
|
has_waived_withdrawal_right: hasWaivedWithdrawalRight,
|
|
129
128
|
});
|
|
130
129
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fetchMock from 'fetch-mock';
|
|
2
|
-
import {
|
|
2
|
+
import { screen } from '@testing-library/react';
|
|
3
3
|
import queryString from 'query-string';
|
|
4
4
|
import {
|
|
5
5
|
RichieContextFactory as mockRichieContextFactory,
|
|
@@ -11,11 +11,9 @@ import {
|
|
|
11
11
|
AddressFactory,
|
|
12
12
|
CredentialOrderFactory,
|
|
13
13
|
CredentialProductFactory,
|
|
14
|
-
OrderGroupFactory,
|
|
15
14
|
} from 'utils/test/factories/joanie';
|
|
16
15
|
import type * as Joanie from 'types/Joanie';
|
|
17
|
-
import {
|
|
18
|
-
import { NOT_CANCELED_ORDER_STATES, OrderCredentialCreationPayload } from 'types/Joanie';
|
|
16
|
+
import { NOT_CANCELED_ORDER_STATES } from 'types/Joanie';
|
|
19
17
|
import { SaleTunnel, SaleTunnelProps } from 'components/SaleTunnel/index';
|
|
20
18
|
import { render } from 'utils/test/render';
|
|
21
19
|
import { getAddressLabel } from 'components/SaleTunnel/AddressSelector';
|
|
@@ -83,11 +81,9 @@ describe('SaleTunnel / Credential', () => {
|
|
|
83
81
|
it('should create an order with an order group', async () => {
|
|
84
82
|
const course = PacedCourseFactory().one();
|
|
85
83
|
const product = CredentialProductFactory().one();
|
|
86
|
-
const orderGroup = OrderGroupFactory().one();
|
|
87
84
|
const billingAddress: Joanie.Address = AddressFactory({ is_main: true }).one();
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
const order = CredentialOrderFactory({ order_group_id: orderGroup.id }).one();
|
|
86
|
+
const order = CredentialOrderFactory().one();
|
|
91
87
|
const orderQueryParameters = {
|
|
92
88
|
course_code: course.code,
|
|
93
89
|
product_id: product.id,
|
|
@@ -100,15 +96,12 @@ describe('SaleTunnel / Credential', () => {
|
|
|
100
96
|
`https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-schedule/`,
|
|
101
97
|
[],
|
|
102
98
|
)
|
|
103
|
-
.post('https://joanie.endpoint/api/v1.0/orders/',
|
|
104
|
-
createOrderPayload = JSON.parse(body as any);
|
|
105
|
-
return order;
|
|
106
|
-
})
|
|
99
|
+
.post('https://joanie.endpoint/api/v1.0/orders/', order)
|
|
107
100
|
.get('https://joanie.endpoint/api/v1.0/addresses/', [billingAddress], {
|
|
108
101
|
overwriteRoutes: true,
|
|
109
102
|
});
|
|
110
103
|
|
|
111
|
-
render(<Wrapper product={product} course={course}
|
|
104
|
+
render(<Wrapper product={product} course={course} />, {
|
|
112
105
|
queryOptions: { client: createTestQueryClient({ user: richieUser }) },
|
|
113
106
|
});
|
|
114
107
|
|
|
@@ -121,12 +114,5 @@ describe('SaleTunnel / Credential', () => {
|
|
|
121
114
|
|
|
122
115
|
// - Payment button should not be disabled.
|
|
123
116
|
expect($button.disabled).toBe(false);
|
|
124
|
-
|
|
125
|
-
// - User clicks on pay button
|
|
126
|
-
await act(async () => {
|
|
127
|
-
fireEvent.click($button);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
await waitFor(() => expect(createOrderPayload?.order_group_id).toEqual(orderGroup.id));
|
|
131
117
|
});
|
|
132
118
|
});
|
|
@@ -15,7 +15,7 @@ import CourseProductItem from 'widgets/SyllabusCourseRunsList/components/CourseP
|
|
|
15
15
|
import {
|
|
16
16
|
AddressFactory,
|
|
17
17
|
ContractFactory,
|
|
18
|
-
|
|
18
|
+
OfferingFactory,
|
|
19
19
|
CredentialOrderFactory,
|
|
20
20
|
CreditCardFactory,
|
|
21
21
|
PaymentFactory,
|
|
@@ -99,7 +99,7 @@ describe('SaleTunnel', () => {
|
|
|
99
99
|
*/
|
|
100
100
|
const course = PacedCourseFactory().one();
|
|
101
101
|
const product = ProductFactory().one();
|
|
102
|
-
const
|
|
102
|
+
const offering = OfferingFactory({
|
|
103
103
|
course,
|
|
104
104
|
product,
|
|
105
105
|
is_withdrawable: false,
|
|
@@ -108,7 +108,7 @@ describe('SaleTunnel', () => {
|
|
|
108
108
|
|
|
109
109
|
fetchMock.get(
|
|
110
110
|
`https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/`,
|
|
111
|
-
|
|
111
|
+
offering,
|
|
112
112
|
);
|
|
113
113
|
fetchMock.get(
|
|
114
114
|
`https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${product.id}/payment-schedule/`,
|