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.
Files changed (86) hide show
  1. package/js/api/joanie.ts +8 -8
  2. package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +11 -19
  3. package/js/components/ContractFrame/OrganizationContractFrame.tsx +4 -4
  4. package/js/components/CourseGlimpse/index.spec.tsx +2 -0
  5. package/js/components/CourseGlimpse/index.tsx +2 -0
  6. package/js/components/CourseGlimpse/utils.ts +29 -30
  7. package/js/components/CourseGlimpseList/utils.ts +2 -2
  8. package/js/components/PurchaseButton/index.tsx +3 -3
  9. package/js/components/SaleTunnel/CredentialSaleTunnel/index.tsx +1 -3
  10. package/js/components/SaleTunnel/GenericSaleTunnel.tsx +3 -1
  11. package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +5 -3
  12. package/js/components/SaleTunnel/SubscriptionButton/index.tsx +1 -2
  13. package/js/components/SaleTunnel/index.credential.spec.tsx +5 -19
  14. package/js/components/SaleTunnel/index.full-process.spec.tsx +3 -3
  15. package/js/components/SaleTunnel/index.spec.tsx +116 -28
  16. package/js/components/SaleTunnel/index.stories.tsx +0 -1
  17. package/js/components/SaleTunnel/index.tsx +2 -2
  18. package/js/components/TeacherDashboardCourseList/index.spec.tsx +3 -3
  19. package/js/components/TeacherDashboardCourseList/index.tsx +2 -2
  20. package/js/hooks/useContractArchive/index.ts +3 -3
  21. package/js/hooks/useCourseProductUnion/index.spec.tsx +16 -18
  22. package/js/hooks/useCourseProductUnion/index.ts +7 -7
  23. package/js/hooks/useCourseProducts.ts +4 -8
  24. package/js/hooks/useDefaultOrganizationId/index.tsx +4 -7
  25. package/js/hooks/useOffering/index.ts +32 -0
  26. package/js/hooks/useTeacherCoursesSearch/index.tsx +2 -2
  27. package/js/hooks/useTeacherPendingContractsCount/index.ts +4 -4
  28. package/js/pages/DashboardCourses/index.spec.tsx +14 -14
  29. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +11 -14
  30. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +4 -9
  31. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +11 -11
  32. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +10 -13
  33. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -4
  34. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +20 -28
  35. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +8 -11
  36. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +6 -6
  37. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +4 -4
  38. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +7 -7
  39. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +5 -5
  40. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +21 -28
  41. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +13 -17
  42. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +11 -13
  43. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +6 -6
  44. package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +3 -3
  45. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +16 -16
  46. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +4 -4
  47. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +4 -4
  48. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx +21 -21
  49. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.ts +5 -10
  50. package/js/pages/TeacherDashboardCourseLearnersLayout/index.spec.tsx +61 -79
  51. package/js/pages/TeacherDashboardCourseLearnersLayout/index.tsx +1 -1
  52. package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +11 -11
  53. package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +11 -11
  54. package/js/pages/TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx +7 -7
  55. package/js/pages/TeacherDashboardTraining/index.spec.tsx +21 -29
  56. package/js/pages/TeacherDashboardTraining/index.tsx +12 -16
  57. package/js/types/Course.ts +2 -0
  58. package/js/types/Joanie.ts +34 -29
  59. package/js/types/index.ts +4 -2
  60. package/js/utils/ProductHelper/index.ts +1 -5
  61. package/js/utils/test/factories/joanie.ts +17 -25
  62. package/js/utils/test/factories/richie.ts +6 -2
  63. package/js/utils/test/mockCourseProductWithOrder.ts +4 -4
  64. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +1 -1
  65. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
  66. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +3 -3
  67. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +1 -1
  68. package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +4 -4
  69. package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +1 -1
  70. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +23 -28
  71. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +4 -8
  72. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +17 -24
  73. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +18 -21
  74. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +4 -4
  75. package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +3 -7
  76. package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +4 -4
  77. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +19 -34
  78. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/_styles.scss +34 -8
  79. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/CourseRunList.tsx +3 -3
  80. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/_styles.scss +9 -0
  81. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +186 -140
  82. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +11 -2
  83. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +111 -24
  84. package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +8 -8
  85. package/package.json +1 -1
  86. 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 { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
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
- courseProductRelation: undefined,
17
+ offering: undefined,
18
18
  existingOrganization: undefined,
19
- existingCourseProductRelation: undefined,
19
+ existingOffering: undefined,
20
20
  },
21
21
  {
22
22
  testLabel: 'for a training in an organization',
23
23
  organization: OrganizationFactory().one(),
24
- courseProductRelation: CourseProductRelationFactory().one(),
24
+ offering: OfferingFactory().one(),
25
25
  existingOrganization: undefined,
26
- existingCourseProductRelation: undefined,
26
+ existingOffering: undefined,
27
27
  },
28
28
  {
29
29
  testLabel: 'for an organization',
30
30
  organization: OrganizationFactory().one(),
31
- courseProductRelation: undefined,
31
+ offering: undefined,
32
32
  existingOrganization: undefined,
33
- existingCourseProductRelation: undefined,
33
+ existingOffering: undefined,
34
34
  },
35
35
  {
36
36
  testLabel: 'for a training',
37
37
  organization: undefined,
38
- courseProductRelation: CourseProductRelationFactory().one(),
38
+ offering: OfferingFactory().one(),
39
39
  existingOrganization: undefined,
40
- existingCourseProductRelation: undefined,
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
- courseProductRelation: undefined,
45
+ offering: undefined,
46
46
  existingOrganization: OrganizationFactory().one(),
47
- existingCourseProductRelation: CourseProductRelationFactory().one(),
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
- courseProductRelation: CourseProductRelationFactory().one(),
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
- courseProductRelation: undefined,
57
+ offering: undefined,
58
58
  existingOrganization: OrganizationFactory().one(),
59
- existingCourseProductRelation: CourseProductRelationFactory().one(),
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
- courseProductRelation: CourseProductRelationFactory().one(),
64
+ offering: OfferingFactory().one(),
65
65
  existingOrganization: OrganizationFactory().one(),
66
- existingCourseProductRelation: CourseProductRelationFactory().one(),
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
- existingCourseProductRelation: CourseProductRelationFactory().one(),
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
- courseProductRelationId: courseProductRelation ? courseProductRelation.id : undefined,
87
+ offeringId: offering ? offering.id : undefined,
93
88
  };
94
89
  localStorageExistingArchiveFilters = {
95
90
  organizationId: existingOrganization ? existingOrganization.id : undefined,
96
- courseProductRelationId: existingCourseProductRelation
97
- ? existingCourseProductRelation.id
98
- : undefined,
91
+ offeringId: existingOffering ? existingOffering.id : undefined,
99
92
  };
100
93
  exsitingContractId = faker.string.uuid();
101
94
 
102
- if (existingCourseProductRelation && existingOrganization) {
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 { CourseProductRelation, Organization } from 'types/Joanie';
2
+ import { Offering, Organization } from 'types/Joanie';
3
3
 
4
4
  export interface LocalStorageArchiveFilters {
5
5
  organizationId?: Organization['id'];
6
- courseProductRelationId?: CourseProductRelation['id'];
6
+ offeringId?: Offering['id'];
7
7
  }
8
8
 
9
9
  const generateLocalStorageKey = ({
10
10
  organizationId,
11
- courseProductRelationId,
11
+ offeringId,
12
12
  }: LocalStorageArchiveFilters = {}) => {
13
- return `${CONTRACT_DOWNLOAD_SETTINGS.contractArchiveLocalStorageKey}::${organizationId ?? 'all'}::${courseProductRelationId ?? '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
- courseProductRelationId,
23
+ offeringId,
24
24
  }: {
25
25
  contractArchiveId: string;
26
26
  organizationId?: Organization['id'];
27
- courseProductRelationId?: CourseProductRelation['id'];
27
+ offeringId?: Offering['id'];
28
28
  }) => {
29
29
  localStorage.setItem(
30
- generateLocalStorageKey({ organizationId, courseProductRelationId }),
30
+ generateLocalStorageKey({ organizationId, offeringId }),
31
31
  generateLocalStorageId(contractArchiveId),
32
32
  );
33
33
  };
34
34
 
35
35
  const unstoreContractArchiveId = ({
36
36
  organizationId,
37
- courseProductRelationId,
37
+ offeringId,
38
38
  }: LocalStorageArchiveFilters = {}) => {
39
- localStorage.removeItem(generateLocalStorageKey({ organizationId, courseProductRelationId }));
39
+ localStorage.removeItem(generateLocalStorageKey({ organizationId, offeringId }));
40
40
  };
41
41
 
42
42
  const getStoredContractArchiveId = ({
43
43
  organizationId,
44
- courseProductRelationId,
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
- courseProductRelationId,
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
  }
@@ -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 { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
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
- courseProductRelation: undefined,
53
+ offering: undefined,
54
54
  },
55
55
  {
56
56
  testLabel: 'for a training in an organization',
57
57
  organization: OrganizationFactory().one(),
58
- courseProductRelation: CourseProductRelationFactory().one(),
58
+ offering: OfferingFactory().one(),
59
59
  },
60
60
  {
61
61
  testLabel: 'for an organization',
62
62
  organization: OrganizationFactory().one(),
63
- courseProductRelation: undefined,
63
+ offering: undefined,
64
64
  },
65
65
  {
66
66
  testLabel: 'for a training',
67
67
  organization: undefined,
68
- courseProductRelation: CourseProductRelationFactory().one(),
68
+ offering: OfferingFactory().one(),
69
69
  },
70
- ])('useDownloadContractArchive $testLabel', ({ organization, courseProductRelation }) => {
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
- courseProductRelationId: courseProductRelation ? courseProductRelation.id : undefined,
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
- existingCourseProductRelation: CourseProductRelationFactory().one(),
100
+ existingOffering: OfferingFactory().one(),
101
101
  },
102
- ])('$testLabel', ({ existingOrganization, existingCourseProductRelation }) => {
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
- courseProductRelationId: existingCourseProductRelation
110
- ? existingCourseProductRelation.id
111
- : undefined,
109
+ offeringId: existingOffering ? existingOffering.id : undefined,
112
110
  };
113
111
  exsitingContractId = faker.string.uuid();
114
112
 
115
- if (existingCourseProductRelation && existingOrganization) {
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 { CourseProductRelation, Organization } from 'types/Joanie';
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
- courseProductRelationId?: CourseProductRelation['id'];
22
+ offeringId?: Offering['id'];
23
23
  }
24
24
 
25
25
  const useDownloadContractArchive = ({
26
26
  organizationId,
27
- courseProductRelationId,
27
+ offeringId,
28
28
  }: UseTeacherContractsBulkDownloadProps) => {
29
29
  const localstorageArchiveFilters = {
30
30
  organizationId,
31
- courseProductRelationId,
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, courseProductRelationId);
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, courseProductRelationId);
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, CourseProductRelation, Organization } from 'types/Joanie';
3
+ import { ContractState, Offering, Organization } from 'types/Joanie';
4
4
 
5
5
  const useHasContractToDownload = (
6
6
  organizationId?: Organization['id'],
7
- courseProductRelationId?: CourseProductRelation['id'],
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
- course_product_relation_id: courseProductRelationId,
14
+ offering_id: offeringId,
15
15
  signature_state: ContractState.SIGNED,
16
16
  page: 1,
17
17
  page_size: PER_PAGE.teacherContractList,
@@ -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 { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
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
- course_product_relation_id: undefined,
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
- course_product_relation_id: undefined,
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 routeCourseProductRelation = CourseProductRelationFactory().one();
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/:courseProductRelationId"
96
- initialEntry={`/${routeOrganization.id}/${routeCourseProductRelation.id}?organization_id=${filteredOrganization.id}&signature_state=${ContractState?.UNSIGNED}&contract_ids=1&contract_ids=2`}
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
- course_product_relation_id: routeCourseProductRelation.id,
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
- course_product_relation_id: routeCourseProductRelation.id,
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 routeCourseProductRelation = CourseProductRelationFactory({ id: 'route' }).one();
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="/:courseProductRelationId"
132
- initialEntry={`/${routeCourseProductRelation.id}/?organization_id=${filteredOrganization.id}&signature_state=${ContractState?.UNSIGNED}&contract_ids=1&contract_ids=2`}
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
- course_product_relation_id: routeCourseProductRelation.id,
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
- course_product_relation_id: routeCourseProductRelation.id,
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 routeCourseProductRelation = CourseProductRelationFactory().one();
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
- course_product_relation_id: undefined,
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
- course_product_relation_id: routeCourseProductRelation.id,
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
- courseProductRelationId?: string;
8
+ offeringId?: string;
9
9
  };
10
10
 
11
11
  const useTeacherContractFilters = () => {
12
- const { courseProductRelationId } = useParams<TeacherDashboardContractsParams>();
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
- course_product_relation_id: searchParams.get('course_product_relation_id') || undefined,
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
- course_product_relation_id: courseProductRelationId,
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, CourseProductRelation } from 'types/Joanie';
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
- courseProductRelationId?: CourseProductRelation['id'];
8
+ offeringId?: Offering['id'];
9
9
  }
10
10
 
11
11
  const useTeacherContractsToSign = ({
12
12
  organizationId,
13
- courseProductRelationId,
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
- course_product_relation_id: courseProductRelationId,
19
+ offering_id: offeringId,
20
20
  },
21
21
  { enabled: !!organizationId },
22
22
  );
@@ -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 { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
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
- course_product_relation_id: undefined,
35
+ offering_id: undefined,
36
36
  });
37
37
  expect(result.current.filters).toStrictEqual({
38
38
  organization_id: undefined,
39
39
  course_id: undefined,
40
- course_product_relation_id: undefined,
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 routeCourseProductRelation = CourseProductRelationFactory().one();
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/:courseProductRelationId',
59
+ path: '/:organizationId/:courseId/:offeringId',
60
60
  initialEntries: [
61
- `/${routeOrganization.id}/${routeCourseProductRelation.course.id}/${routeCourseProductRelation.id}?organization_id=${filteredOrganization.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: routeCourseProductRelation.course.id,
74
- course_product_relation_id: routeCourseProductRelation.id,
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: routeCourseProductRelation.course.id,
79
- course_product_relation_id: routeCourseProductRelation.id,
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 routeCourseProductRelation = CourseProductRelationFactory({ id: 'route' }).one();
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/:courseProductRelationId',
97
+ path: '/:courseId/:offeringId',
98
98
  initialEntries: [
99
- `/${routeCourseProductRelation.course.id}/${routeCourseProductRelation.id}/?organization_id=${filteredOrganization.id}`,
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: routeCourseProductRelation.course.id,
112
- course_product_relation_id: routeCourseProductRelation.id,
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: routeCourseProductRelation.course.id,
117
- course_product_relation_id: routeCourseProductRelation.id,
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 routeCourseProductRelation = CourseProductRelationFactory().one();
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
- course_product_relation_id: undefined,
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: routeCourseProductRelation.course.id,
148
- course_product_relation_id: routeCourseProductRelation.id,
147
+ course_id: routeOffering.course.id,
148
+ offering_id: routeOffering.id,
149
149
  };
150
150
  act(() => {
151
151
  result.current.setFilters(newFilters);