richie-education 3.1.3-dev2 → 3.1.3-dev23
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/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 +3 -1
- package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +5 -3
- 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 +116 -28
- package/js/components/SaleTunnel/index.stories.tsx +0 -1
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { faker } from '@faker-js/faker';
|
|
2
2
|
import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
|
|
3
|
-
import {
|
|
3
|
+
import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
|
|
4
4
|
import {
|
|
5
5
|
LocalStorageArchiveFilters,
|
|
6
6
|
generateLocalStorageKey,
|
|
@@ -14,56 +14,56 @@ describe.each([
|
|
|
14
14
|
{
|
|
15
15
|
testLabel: 'for all organization and all trainings',
|
|
16
16
|
organization: undefined,
|
|
17
|
-
|
|
17
|
+
offering: undefined,
|
|
18
18
|
existingOrganization: undefined,
|
|
19
|
-
|
|
19
|
+
existingOffering: undefined,
|
|
20
20
|
},
|
|
21
21
|
{
|
|
22
22
|
testLabel: 'for a training in an organization',
|
|
23
23
|
organization: OrganizationFactory().one(),
|
|
24
|
-
|
|
24
|
+
offering: OfferingFactory().one(),
|
|
25
25
|
existingOrganization: undefined,
|
|
26
|
-
|
|
26
|
+
existingOffering: undefined,
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
testLabel: 'for an organization',
|
|
30
30
|
organization: OrganizationFactory().one(),
|
|
31
|
-
|
|
31
|
+
offering: undefined,
|
|
32
32
|
existingOrganization: undefined,
|
|
33
|
-
|
|
33
|
+
existingOffering: undefined,
|
|
34
34
|
},
|
|
35
35
|
{
|
|
36
36
|
testLabel: 'for a training',
|
|
37
37
|
organization: undefined,
|
|
38
|
-
|
|
38
|
+
offering: OfferingFactory().one(),
|
|
39
39
|
existingOrganization: undefined,
|
|
40
|
-
|
|
40
|
+
existingOffering: undefined,
|
|
41
41
|
},
|
|
42
42
|
{
|
|
43
43
|
testLabel: 'for all organization and all trainings, with a other id already stored',
|
|
44
44
|
organization: undefined,
|
|
45
|
-
|
|
45
|
+
offering: undefined,
|
|
46
46
|
existingOrganization: OrganizationFactory().one(),
|
|
47
|
-
|
|
47
|
+
existingOffering: OfferingFactory().one(),
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
50
|
testLabel: 'for a training in an organization, with a other id already stored',
|
|
51
51
|
organization: OrganizationFactory().one(),
|
|
52
|
-
|
|
52
|
+
offering: OfferingFactory().one(),
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
testLabel: 'for an organization, with a other id already stored',
|
|
56
56
|
organization: OrganizationFactory().one(),
|
|
57
|
-
|
|
57
|
+
offering: undefined,
|
|
58
58
|
existingOrganization: OrganizationFactory().one(),
|
|
59
|
-
|
|
59
|
+
existingOffering: OfferingFactory().one(),
|
|
60
60
|
},
|
|
61
61
|
{
|
|
62
62
|
testLabel: 'for a training, with a other id already stored',
|
|
63
63
|
organization: undefined,
|
|
64
|
-
|
|
64
|
+
offering: OfferingFactory().one(),
|
|
65
65
|
existingOrganization: OrganizationFactory().one(),
|
|
66
|
-
|
|
66
|
+
existingOffering: OfferingFactory().one(),
|
|
67
67
|
},
|
|
68
68
|
|
|
69
69
|
{
|
|
@@ -72,16 +72,11 @@ describe.each([
|
|
|
72
72
|
{
|
|
73
73
|
testLabel: 'Testing with a other id already stored',
|
|
74
74
|
existingOrganization: OrganizationFactory().one(),
|
|
75
|
-
|
|
75
|
+
existingOffering: OfferingFactory().one(),
|
|
76
76
|
},
|
|
77
77
|
])(
|
|
78
78
|
'contractArchiveLocalStorage $testLabel',
|
|
79
|
-
({
|
|
80
|
-
organization,
|
|
81
|
-
courseProductRelation,
|
|
82
|
-
existingOrganization,
|
|
83
|
-
existingCourseProductRelation,
|
|
84
|
-
}) => {
|
|
79
|
+
({ organization, offering, existingOrganization, existingOffering }) => {
|
|
85
80
|
let localStorageArchiveFilters: LocalStorageArchiveFilters;
|
|
86
81
|
let localStorageExistingArchiveFilters: LocalStorageArchiveFilters;
|
|
87
82
|
let exsitingContractId: string;
|
|
@@ -89,17 +84,15 @@ describe.each([
|
|
|
89
84
|
beforeEach(() => {
|
|
90
85
|
localStorageArchiveFilters = {
|
|
91
86
|
organizationId: organization ? organization.id : undefined,
|
|
92
|
-
|
|
87
|
+
offeringId: offering ? offering.id : undefined,
|
|
93
88
|
};
|
|
94
89
|
localStorageExistingArchiveFilters = {
|
|
95
90
|
organizationId: existingOrganization ? existingOrganization.id : undefined,
|
|
96
|
-
|
|
97
|
-
? existingCourseProductRelation.id
|
|
98
|
-
: undefined,
|
|
91
|
+
offeringId: existingOffering ? existingOffering.id : undefined,
|
|
99
92
|
};
|
|
100
93
|
exsitingContractId = faker.string.uuid();
|
|
101
94
|
|
|
102
|
-
if (
|
|
95
|
+
if (existingOffering && existingOrganization) {
|
|
103
96
|
// everything should work fine with multiple archive stored
|
|
104
97
|
storeContractArchiveId({
|
|
105
98
|
...localStorageExistingArchiveFilters,
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
|
|
2
|
-
import {
|
|
2
|
+
import { Offering, Organization } from 'types/Joanie';
|
|
3
3
|
|
|
4
4
|
export interface LocalStorageArchiveFilters {
|
|
5
5
|
organizationId?: Organization['id'];
|
|
6
|
-
|
|
6
|
+
offeringId?: Offering['id'];
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const generateLocalStorageKey = ({
|
|
10
10
|
organizationId,
|
|
11
|
-
|
|
11
|
+
offeringId,
|
|
12
12
|
}: LocalStorageArchiveFilters = {}) => {
|
|
13
|
-
return `${CONTRACT_DOWNLOAD_SETTINGS.contractArchiveLocalStorageKey}::${organizationId ?? 'all'}::${
|
|
13
|
+
return `${CONTRACT_DOWNLOAD_SETTINGS.contractArchiveLocalStorageKey}::${organizationId ?? 'all'}::${offeringId ?? 'all'}`;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
const generateLocalStorageId = (contractArchiveId: string) => {
|
|
@@ -20,32 +20,30 @@ const generateLocalStorageId = (contractArchiveId: string) => {
|
|
|
20
20
|
const storeContractArchiveId = ({
|
|
21
21
|
contractArchiveId,
|
|
22
22
|
organizationId,
|
|
23
|
-
|
|
23
|
+
offeringId,
|
|
24
24
|
}: {
|
|
25
25
|
contractArchiveId: string;
|
|
26
26
|
organizationId?: Organization['id'];
|
|
27
|
-
|
|
27
|
+
offeringId?: Offering['id'];
|
|
28
28
|
}) => {
|
|
29
29
|
localStorage.setItem(
|
|
30
|
-
generateLocalStorageKey({ organizationId,
|
|
30
|
+
generateLocalStorageKey({ organizationId, offeringId }),
|
|
31
31
|
generateLocalStorageId(contractArchiveId),
|
|
32
32
|
);
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const unstoreContractArchiveId = ({
|
|
36
36
|
organizationId,
|
|
37
|
-
|
|
37
|
+
offeringId,
|
|
38
38
|
}: LocalStorageArchiveFilters = {}) => {
|
|
39
|
-
localStorage.removeItem(generateLocalStorageKey({ organizationId,
|
|
39
|
+
localStorage.removeItem(generateLocalStorageKey({ organizationId, offeringId }));
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
const getStoredContractArchiveId = ({
|
|
43
43
|
organizationId,
|
|
44
|
-
|
|
44
|
+
offeringId,
|
|
45
45
|
}: LocalStorageArchiveFilters = {}) => {
|
|
46
|
-
const value = localStorage.getItem(
|
|
47
|
-
generateLocalStorageKey({ organizationId, courseProductRelationId }),
|
|
48
|
-
);
|
|
46
|
+
const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offeringId }));
|
|
49
47
|
if (value === null) {
|
|
50
48
|
return value;
|
|
51
49
|
}
|
|
@@ -56,11 +54,9 @@ const getStoredContractArchiveId = ({
|
|
|
56
54
|
|
|
57
55
|
const isStoredContractArchiveIdExpired = ({
|
|
58
56
|
organizationId,
|
|
59
|
-
|
|
57
|
+
offeringId,
|
|
60
58
|
}: LocalStorageArchiveFilters = {}) => {
|
|
61
|
-
const value = localStorage.getItem(
|
|
62
|
-
generateLocalStorageKey({ organizationId, courseProductRelationId }),
|
|
63
|
-
);
|
|
59
|
+
const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offeringId }));
|
|
64
60
|
if (value === null) {
|
|
65
61
|
return false;
|
|
66
62
|
}
|
package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { PropsWithChildren } from 'react';
|
|
|
5
5
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
6
6
|
import JoanieApiProvider from 'contexts/JoanieApiContext';
|
|
7
7
|
import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
|
|
8
|
-
import {
|
|
8
|
+
import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
|
|
9
9
|
import {
|
|
10
10
|
LocalStorageArchiveFilters,
|
|
11
11
|
getStoredContractArchiveId,
|
|
@@ -50,30 +50,30 @@ describe.each([
|
|
|
50
50
|
{
|
|
51
51
|
testLabel: 'for all organization and all trainings',
|
|
52
52
|
organization: undefined,
|
|
53
|
-
|
|
53
|
+
offering: undefined,
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
testLabel: 'for a training in an organization',
|
|
57
57
|
organization: OrganizationFactory().one(),
|
|
58
|
-
|
|
58
|
+
offering: OfferingFactory().one(),
|
|
59
59
|
},
|
|
60
60
|
{
|
|
61
61
|
testLabel: 'for an organization',
|
|
62
62
|
organization: OrganizationFactory().one(),
|
|
63
|
-
|
|
63
|
+
offering: undefined,
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
testLabel: 'for a training',
|
|
67
67
|
organization: undefined,
|
|
68
|
-
|
|
68
|
+
offering: OfferingFactory().one(),
|
|
69
69
|
},
|
|
70
|
-
])('useDownloadContractArchive $testLabel', ({ organization,
|
|
70
|
+
])('useDownloadContractArchive $testLabel', ({ organization, offering }) => {
|
|
71
71
|
let localStorageArchiveFilters: LocalStorageArchiveFilters;
|
|
72
72
|
|
|
73
73
|
beforeEach(() => {
|
|
74
74
|
localStorageArchiveFilters = {
|
|
75
75
|
organizationId: organization ? organization.id : undefined,
|
|
76
|
-
|
|
76
|
+
offeringId: offering ? offering.id : undefined,
|
|
77
77
|
};
|
|
78
78
|
});
|
|
79
79
|
|
|
@@ -97,22 +97,20 @@ describe.each([
|
|
|
97
97
|
{
|
|
98
98
|
testLabel: 'Testing with a other id already stored',
|
|
99
99
|
existingOrganization: OrganizationFactory().one(),
|
|
100
|
-
|
|
100
|
+
existingOffering: OfferingFactory().one(),
|
|
101
101
|
},
|
|
102
|
-
])('$testLabel', ({ existingOrganization,
|
|
102
|
+
])('$testLabel', ({ existingOrganization, existingOffering }) => {
|
|
103
103
|
let localStorageExistingArchiveFilters: LocalStorageArchiveFilters;
|
|
104
104
|
let exsitingContractId: string;
|
|
105
105
|
|
|
106
106
|
beforeEach(() => {
|
|
107
107
|
localStorageExistingArchiveFilters = {
|
|
108
108
|
organizationId: existingOrganization ? existingOrganization.id : undefined,
|
|
109
|
-
|
|
110
|
-
? existingCourseProductRelation.id
|
|
111
|
-
: undefined,
|
|
109
|
+
offeringId: existingOffering ? existingOffering.id : undefined,
|
|
112
110
|
};
|
|
113
111
|
exsitingContractId = faker.string.uuid();
|
|
114
112
|
|
|
115
|
-
if (
|
|
113
|
+
if (existingOffering && existingOrganization) {
|
|
116
114
|
// everything should work fine with multiple archive stored
|
|
117
115
|
storeContractArchiveId({
|
|
118
116
|
...localStorageExistingArchiveFilters,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import useContractArchive from 'hooks/useContractArchive';
|
|
3
|
-
import {
|
|
3
|
+
import { Offering, Organization } from 'types/Joanie';
|
|
4
4
|
import useCheckContractArchiveExists from '../useCheckContractArchiveExists';
|
|
5
5
|
import useHasContractToDownload from '../useHasContractToDownload';
|
|
6
6
|
import {
|
|
@@ -19,16 +19,16 @@ export enum ContractDownloadStatus {
|
|
|
19
19
|
|
|
20
20
|
interface UseTeacherContractsBulkDownloadProps {
|
|
21
21
|
organizationId?: Organization['id'];
|
|
22
|
-
|
|
22
|
+
offeringId?: Offering['id'];
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const useDownloadContractArchive = ({
|
|
26
26
|
organizationId,
|
|
27
|
-
|
|
27
|
+
offeringId,
|
|
28
28
|
}: UseTeacherContractsBulkDownloadProps) => {
|
|
29
29
|
const localstorageArchiveFilters = {
|
|
30
30
|
organizationId,
|
|
31
|
-
|
|
31
|
+
offeringId,
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
// Contract's archive api interface
|
|
@@ -37,7 +37,7 @@ const useDownloadContractArchive = ({
|
|
|
37
37
|
} = useContractArchive();
|
|
38
38
|
|
|
39
39
|
// Simple hook that verifiy if current user have some fully signed contracts to download.
|
|
40
|
-
const hasContractToDownload = useHasContractToDownload(organizationId,
|
|
40
|
+
const hasContractToDownload = useHasContractToDownload(organizationId, offeringId);
|
|
41
41
|
|
|
42
42
|
// Component state of the localstorage contract's archive id
|
|
43
43
|
const [contractArchiveId, setContractArchiveId] = useState<string | null>(
|
|
@@ -116,7 +116,7 @@ const useDownloadContractArchive = ({
|
|
|
116
116
|
const createContractArchive = async () => {
|
|
117
117
|
let newContractArchiveId;
|
|
118
118
|
if (contractArchiveId === null) {
|
|
119
|
-
newContractArchiveId = await createArchive(organizationId,
|
|
119
|
+
newContractArchiveId = await createArchive(organizationId, offeringId);
|
|
120
120
|
setContractArchiveId(newContractArchiveId);
|
|
121
121
|
storeContractArchiveId({
|
|
122
122
|
...localstorageArchiveFilters,
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { useOrganizationContracts } from 'hooks/useContracts';
|
|
2
2
|
import { PER_PAGE } from 'settings';
|
|
3
|
-
import { ContractState,
|
|
3
|
+
import { ContractState, Offering, Organization } from 'types/Joanie';
|
|
4
4
|
|
|
5
5
|
const useHasContractToDownload = (
|
|
6
6
|
organizationId?: Organization['id'],
|
|
7
|
-
|
|
7
|
+
offeringId?: Offering['id'],
|
|
8
8
|
) => {
|
|
9
9
|
const {
|
|
10
10
|
items: contracts,
|
|
11
11
|
states: { isFetched },
|
|
12
12
|
} = useOrganizationContracts({
|
|
13
13
|
organization_id: organizationId,
|
|
14
|
-
|
|
14
|
+
offering_id: offeringId,
|
|
15
15
|
signature_state: ContractState.SIGNED,
|
|
16
16
|
page: 1,
|
|
17
17
|
page_size: PER_PAGE.teacherContractList,
|
package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import { MemoryRouter, Route, Routes } from 'react-router';
|
|
|
7
7
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
8
8
|
import { createTestQueryClient } from 'utils/test/createTestQueryClient';
|
|
9
9
|
import JoanieSessionProvider from 'contexts/SessionContext/JoanieSessionProvider';
|
|
10
|
-
import {
|
|
10
|
+
import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
|
|
11
11
|
import { ContractState } from 'types/Joanie';
|
|
12
12
|
import useTeacherContractFilters from '.';
|
|
13
13
|
|
|
@@ -67,13 +67,13 @@ describe('useTeacherContractFilters', () => {
|
|
|
67
67
|
expect(result.current.initialFilters).toStrictEqual({
|
|
68
68
|
contract_ids: [],
|
|
69
69
|
organization_id: defaultOrganization.id,
|
|
70
|
-
|
|
70
|
+
offering_id: undefined,
|
|
71
71
|
signature_state: ContractState.SIGNED,
|
|
72
72
|
});
|
|
73
73
|
expect(result.current.filters).toStrictEqual({
|
|
74
74
|
contract_ids: [],
|
|
75
75
|
organization_id: defaultOrganization.id,
|
|
76
|
-
|
|
76
|
+
offering_id: undefined,
|
|
77
77
|
signature_state: ContractState.SIGNED,
|
|
78
78
|
});
|
|
79
79
|
});
|
|
@@ -83,7 +83,7 @@ describe('useTeacherContractFilters', () => {
|
|
|
83
83
|
const defaultOrganization = OrganizationFactory({ id: 'default' }).one();
|
|
84
84
|
const filteredOrganization = OrganizationFactory({ id: 'filtered' }).one();
|
|
85
85
|
const routeOrganization = OrganizationFactory({ id: 'route' }).one();
|
|
86
|
-
const
|
|
86
|
+
const routeOffering = OfferingFactory().one();
|
|
87
87
|
// fetching user's organizations to initialize default organizationId.
|
|
88
88
|
fetchMock.get('https://joanie.test/api/v1.0/organizations/', [
|
|
89
89
|
defaultOrganization,
|
|
@@ -92,8 +92,8 @@ describe('useTeacherContractFilters', () => {
|
|
|
92
92
|
const { result } = renderHook(useTeacherContractFilters, {
|
|
93
93
|
wrapper: ({ children }) => (
|
|
94
94
|
<Wrapper
|
|
95
|
-
routePath="/:organizationId/:
|
|
96
|
-
initialEntry={`/${routeOrganization.id}/${
|
|
95
|
+
routePath="/:organizationId/:offeringId"
|
|
96
|
+
initialEntry={`/${routeOrganization.id}/${routeOffering.id}?organization_id=${filteredOrganization.id}&signature_state=${ContractState?.UNSIGNED}&contract_ids=1&contract_ids=2`}
|
|
97
97
|
>
|
|
98
98
|
{children}
|
|
99
99
|
</Wrapper>
|
|
@@ -104,13 +104,13 @@ describe('useTeacherContractFilters', () => {
|
|
|
104
104
|
expect(result.current.initialFilters).toStrictEqual({
|
|
105
105
|
contract_ids: ['1', '2'],
|
|
106
106
|
organization_id: routeOrganization.id,
|
|
107
|
-
|
|
107
|
+
offering_id: routeOffering.id,
|
|
108
108
|
signature_state: ContractState.UNSIGNED,
|
|
109
109
|
});
|
|
110
110
|
expect(result.current.filters).toStrictEqual({
|
|
111
111
|
contract_ids: ['1', '2'],
|
|
112
112
|
organization_id: routeOrganization.id,
|
|
113
|
-
|
|
113
|
+
offering_id: routeOffering.id,
|
|
114
114
|
signature_state: ContractState.UNSIGNED,
|
|
115
115
|
});
|
|
116
116
|
});
|
|
@@ -119,7 +119,7 @@ describe('useTeacherContractFilters', () => {
|
|
|
119
119
|
it("should use organizationId from query parameters when it's not in route params", async () => {
|
|
120
120
|
const defaultOrganization = OrganizationFactory({ id: 'default' }).one();
|
|
121
121
|
const filteredOrganization = OrganizationFactory({ id: 'filtered' }).one();
|
|
122
|
-
const
|
|
122
|
+
const routeOffering = OfferingFactory({ id: 'route' }).one();
|
|
123
123
|
// fetching user's organizations to initialize default organizationId.
|
|
124
124
|
fetchMock.get('https://joanie.test/api/v1.0/organizations/', [
|
|
125
125
|
defaultOrganization,
|
|
@@ -128,8 +128,8 @@ describe('useTeacherContractFilters', () => {
|
|
|
128
128
|
const { result } = renderHook(useTeacherContractFilters, {
|
|
129
129
|
wrapper: ({ children }) => (
|
|
130
130
|
<Wrapper
|
|
131
|
-
routePath="/:
|
|
132
|
-
initialEntry={`/${
|
|
131
|
+
routePath="/:offeringId"
|
|
132
|
+
initialEntry={`/${routeOffering.id}/?organization_id=${filteredOrganization.id}&signature_state=${ContractState?.UNSIGNED}&contract_ids=1&contract_ids=2`}
|
|
133
133
|
>
|
|
134
134
|
{children}
|
|
135
135
|
</Wrapper>
|
|
@@ -140,13 +140,13 @@ describe('useTeacherContractFilters', () => {
|
|
|
140
140
|
expect(result.current.initialFilters).toStrictEqual({
|
|
141
141
|
contract_ids: ['1', '2'],
|
|
142
142
|
organization_id: filteredOrganization.id,
|
|
143
|
-
|
|
143
|
+
offering_id: routeOffering.id,
|
|
144
144
|
signature_state: ContractState.UNSIGNED,
|
|
145
145
|
});
|
|
146
146
|
expect(result.current.filters).toStrictEqual({
|
|
147
147
|
contract_ids: ['1', '2'],
|
|
148
148
|
organization_id: filteredOrganization.id,
|
|
149
|
-
|
|
149
|
+
offering_id: routeOffering.id,
|
|
150
150
|
signature_state: ContractState.UNSIGNED,
|
|
151
151
|
});
|
|
152
152
|
});
|
|
@@ -155,7 +155,7 @@ describe('useTeacherContractFilters', () => {
|
|
|
155
155
|
it('setFilters should update filter state', async () => {
|
|
156
156
|
const defaultOrganization = OrganizationFactory({ id: 'default' }).one();
|
|
157
157
|
const routeOrganization = OrganizationFactory({ id: 'route' }).one();
|
|
158
|
-
const
|
|
158
|
+
const routeOffering = OfferingFactory().one();
|
|
159
159
|
// fetching user's organizations to initialize default organizationId.
|
|
160
160
|
fetchMock.get('https://joanie.test/api/v1.0/organizations/', [defaultOrganization]);
|
|
161
161
|
const { result } = renderHook(useTeacherContractFilters, {
|
|
@@ -169,7 +169,7 @@ describe('useTeacherContractFilters', () => {
|
|
|
169
169
|
const expectedInitialFilters = {
|
|
170
170
|
contract_ids: [],
|
|
171
171
|
organization_id: defaultOrganization.id,
|
|
172
|
-
|
|
172
|
+
offering_id: undefined,
|
|
173
173
|
signature_state: ContractState.SIGNED,
|
|
174
174
|
};
|
|
175
175
|
await waitFor(() => {
|
|
@@ -179,7 +179,7 @@ describe('useTeacherContractFilters', () => {
|
|
|
179
179
|
const newFilters = {
|
|
180
180
|
contract_ids: ['1', '2'],
|
|
181
181
|
organization_id: routeOrganization.id,
|
|
182
|
-
|
|
182
|
+
offering_id: routeOffering.id,
|
|
183
183
|
signature_state: ContractState.UNSIGNED,
|
|
184
184
|
};
|
|
185
185
|
act(() => {
|
|
@@ -5,16 +5,16 @@ import { ContractResourceQuery, ContractState } from 'types/Joanie';
|
|
|
5
5
|
|
|
6
6
|
export type TeacherDashboardContractsParams = {
|
|
7
7
|
organizationId?: string;
|
|
8
|
-
|
|
8
|
+
offeringId?: string;
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const useTeacherContractFilters = () => {
|
|
12
|
-
const {
|
|
12
|
+
const { offeringId } = useParams<TeacherDashboardContractsParams>();
|
|
13
13
|
const [searchParams] = useSearchParams();
|
|
14
14
|
const searchFilters: ContractResourceQuery = useMemo(() => {
|
|
15
15
|
return {
|
|
16
16
|
organization_id: searchParams.get('organization_id') || undefined,
|
|
17
|
-
|
|
17
|
+
offering_id: searchParams.get('offering_id') || undefined,
|
|
18
18
|
contract_ids: searchParams.getAll('contract_ids') || undefined,
|
|
19
19
|
signature_state:
|
|
20
20
|
(searchParams.get('signature_state') as ContractState) || ContractState.SIGNED,
|
|
@@ -28,7 +28,7 @@ const useTeacherContractFilters = () => {
|
|
|
28
28
|
return {
|
|
29
29
|
...searchFilters,
|
|
30
30
|
organization_id: defaultOrganizationId,
|
|
31
|
-
|
|
31
|
+
offering_id: offeringId,
|
|
32
32
|
};
|
|
33
33
|
}, [defaultOrganizationId]);
|
|
34
34
|
const [filters, setFilters] = useState<ContractResourceQuery>(initialFilters);
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import useContractAbilities from 'hooks/useContractAbilities';
|
|
2
2
|
import { useOrganizationContracts } from 'hooks/useContracts';
|
|
3
|
-
import { ContractState, Organization,
|
|
3
|
+
import { ContractState, Organization, Offering } from 'types/Joanie';
|
|
4
4
|
import { ContractActions } from 'utils/AbilitiesHelper/types';
|
|
5
5
|
|
|
6
6
|
interface UseTeacherContractsToSignProps {
|
|
7
7
|
organizationId?: Organization['id'];
|
|
8
|
-
|
|
8
|
+
offeringId?: Offering['id'];
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
const useTeacherContractsToSign = ({
|
|
12
12
|
organizationId,
|
|
13
|
-
|
|
13
|
+
offeringId,
|
|
14
14
|
}: UseTeacherContractsToSignProps) => {
|
|
15
15
|
const { items: contractsToSign, meta: contractsToSignMeta } = useOrganizationContracts(
|
|
16
16
|
{
|
|
17
17
|
signature_state: ContractState.LEARNER_SIGNED,
|
|
18
18
|
organization_id: organizationId,
|
|
19
|
-
|
|
19
|
+
offering_id: offeringId,
|
|
20
20
|
},
|
|
21
21
|
{ enabled: !!organizationId },
|
|
22
22
|
);
|
package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import fetchMock from 'fetch-mock';
|
|
2
2
|
import { renderHook, waitFor, act } from '@testing-library/react';
|
|
3
3
|
import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
|
|
4
|
-
import {
|
|
4
|
+
import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
|
|
5
5
|
import { JoanieAppWrapper, setupJoanieSession } from 'utils/test/wrappers/JoanieAppWrapper';
|
|
6
6
|
import useCourseLearnersFilters from '.';
|
|
7
7
|
|
|
@@ -32,12 +32,12 @@ describe('useCourseLearnersFilters', () => {
|
|
|
32
32
|
expect(result.current.initialFilters).toStrictEqual({
|
|
33
33
|
organization_id: undefined,
|
|
34
34
|
course_id: undefined,
|
|
35
|
-
|
|
35
|
+
offering_id: undefined,
|
|
36
36
|
});
|
|
37
37
|
expect(result.current.filters).toStrictEqual({
|
|
38
38
|
organization_id: undefined,
|
|
39
39
|
course_id: undefined,
|
|
40
|
-
|
|
40
|
+
offering_id: undefined,
|
|
41
41
|
});
|
|
42
42
|
});
|
|
43
43
|
});
|
|
@@ -46,7 +46,7 @@ describe('useCourseLearnersFilters', () => {
|
|
|
46
46
|
const defaultOrganization = OrganizationFactory().one();
|
|
47
47
|
const filteredOrganization = OrganizationFactory({ id: 'filtered' }).one();
|
|
48
48
|
const routeOrganization = OrganizationFactory({ id: 'route' }).one();
|
|
49
|
-
const
|
|
49
|
+
const routeOffering = OfferingFactory().one();
|
|
50
50
|
// fetching user's organizations to initialize default organizationId.
|
|
51
51
|
fetchMock.get('https://joanie.endpoint/api/v1.0/organizations/', [
|
|
52
52
|
defaultOrganization,
|
|
@@ -56,9 +56,9 @@ describe('useCourseLearnersFilters', () => {
|
|
|
56
56
|
wrapper: ({ children }) => (
|
|
57
57
|
<JoanieAppWrapper
|
|
58
58
|
routerOptions={{
|
|
59
|
-
path: '/:organizationId/:courseId/:
|
|
59
|
+
path: '/:organizationId/:courseId/:offeringId',
|
|
60
60
|
initialEntries: [
|
|
61
|
-
`/${routeOrganization.id}/${
|
|
61
|
+
`/${routeOrganization.id}/${routeOffering.course.id}/${routeOffering.id}?organization_id=${filteredOrganization.id}`,
|
|
62
62
|
],
|
|
63
63
|
}}
|
|
64
64
|
>
|
|
@@ -70,13 +70,13 @@ describe('useCourseLearnersFilters', () => {
|
|
|
70
70
|
await waitFor(() => {
|
|
71
71
|
expect(result.current.initialFilters).toStrictEqual({
|
|
72
72
|
organization_id: routeOrganization.id,
|
|
73
|
-
course_id:
|
|
74
|
-
|
|
73
|
+
course_id: routeOffering.course.id,
|
|
74
|
+
offering_id: routeOffering.id,
|
|
75
75
|
});
|
|
76
76
|
expect(result.current.filters).toStrictEqual({
|
|
77
77
|
organization_id: routeOrganization.id,
|
|
78
|
-
course_id:
|
|
79
|
-
|
|
78
|
+
course_id: routeOffering.course.id,
|
|
79
|
+
offering_id: routeOffering.id,
|
|
80
80
|
});
|
|
81
81
|
});
|
|
82
82
|
});
|
|
@@ -84,7 +84,7 @@ describe('useCourseLearnersFilters', () => {
|
|
|
84
84
|
it("should use organizationId from query parameters when it's not in route params", async () => {
|
|
85
85
|
const defaultOrganization = OrganizationFactory().one();
|
|
86
86
|
const filteredOrganization = OrganizationFactory({ id: 'filtered' }).one();
|
|
87
|
-
const
|
|
87
|
+
const routeOffering = OfferingFactory({ id: 'route' }).one();
|
|
88
88
|
// fetching user's organizations to initialize default organizationId.
|
|
89
89
|
fetchMock.get('https://joanie.endpoint/api/v1.0/organizations/', [
|
|
90
90
|
defaultOrganization,
|
|
@@ -94,9 +94,9 @@ describe('useCourseLearnersFilters', () => {
|
|
|
94
94
|
wrapper: ({ children }) => (
|
|
95
95
|
<JoanieAppWrapper
|
|
96
96
|
routerOptions={{
|
|
97
|
-
path: '/:courseId/:
|
|
97
|
+
path: '/:courseId/:offeringId',
|
|
98
98
|
initialEntries: [
|
|
99
|
-
`/${
|
|
99
|
+
`/${routeOffering.course.id}/${routeOffering.id}/?organization_id=${filteredOrganization.id}`,
|
|
100
100
|
],
|
|
101
101
|
}}
|
|
102
102
|
>
|
|
@@ -108,13 +108,13 @@ describe('useCourseLearnersFilters', () => {
|
|
|
108
108
|
await waitFor(() => {
|
|
109
109
|
expect(result.current.initialFilters).toStrictEqual({
|
|
110
110
|
organization_id: filteredOrganization.id,
|
|
111
|
-
course_id:
|
|
112
|
-
|
|
111
|
+
course_id: routeOffering.course.id,
|
|
112
|
+
offering_id: routeOffering.id,
|
|
113
113
|
});
|
|
114
114
|
expect(result.current.filters).toStrictEqual({
|
|
115
115
|
organization_id: filteredOrganization.id,
|
|
116
|
-
course_id:
|
|
117
|
-
|
|
116
|
+
course_id: routeOffering.course.id,
|
|
117
|
+
offering_id: routeOffering.id,
|
|
118
118
|
});
|
|
119
119
|
});
|
|
120
120
|
});
|
|
@@ -122,7 +122,7 @@ describe('useCourseLearnersFilters', () => {
|
|
|
122
122
|
it('setFilters should update filter state', async () => {
|
|
123
123
|
const defaultOrganization = OrganizationFactory({ id: 'all' }).one();
|
|
124
124
|
const routeOrganization = OrganizationFactory({ id: 'route' }).one();
|
|
125
|
-
const
|
|
125
|
+
const routeOffering = OfferingFactory().one();
|
|
126
126
|
// fetching user's organizations to initialize default organizationId.
|
|
127
127
|
fetchMock.get('https://joanie.endpoint/api/v1.0/organizations/', [defaultOrganization]);
|
|
128
128
|
const { result } = renderHook(useCourseLearnersFilters, {
|
|
@@ -136,7 +136,7 @@ describe('useCourseLearnersFilters', () => {
|
|
|
136
136
|
const expectedInitialFilters = {
|
|
137
137
|
organization_id: defaultOrganization.id,
|
|
138
138
|
course_id: undefined,
|
|
139
|
-
|
|
139
|
+
offering_id: undefined,
|
|
140
140
|
};
|
|
141
141
|
await waitFor(() => {
|
|
142
142
|
expect(result.current.initialFilters).toStrictEqual(expectedInitialFilters);
|
|
@@ -144,8 +144,8 @@ describe('useCourseLearnersFilters', () => {
|
|
|
144
144
|
|
|
145
145
|
const newFilters = {
|
|
146
146
|
organization_id: routeOrganization.id,
|
|
147
|
-
course_id:
|
|
148
|
-
|
|
147
|
+
course_id: routeOffering.course.id,
|
|
148
|
+
offering_id: routeOffering.id,
|
|
149
149
|
};
|
|
150
150
|
act(() => {
|
|
151
151
|
result.current.setFilters(newFilters);
|