richie-education 3.1.3-dev12 → 3.1.3-dev17

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 (73) hide show
  1. package/js/api/joanie.ts +8 -8
  2. package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +12 -11
  3. package/js/components/ContractFrame/OrganizationContractFrame.tsx +4 -4
  4. package/js/components/CourseGlimpse/utils.ts +28 -22
  5. package/js/components/CourseGlimpseList/utils.ts +2 -2
  6. package/js/components/PurchaseButton/index.tsx +3 -3
  7. package/js/components/SaleTunnel/GenericSaleTunnel.tsx +3 -3
  8. package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +5 -3
  9. package/js/components/SaleTunnel/index.full-process.spec.tsx +3 -3
  10. package/js/components/SaleTunnel/index.spec.tsx +76 -63
  11. package/js/components/SaleTunnel/index.tsx +2 -2
  12. package/js/components/TeacherDashboardCourseList/index.spec.tsx +3 -3
  13. package/js/components/TeacherDashboardCourseList/index.tsx +2 -2
  14. package/js/hooks/useContractArchive/index.ts +3 -3
  15. package/js/hooks/useCourseProductUnion/index.spec.tsx +16 -16
  16. package/js/hooks/useCourseProductUnion/index.ts +7 -7
  17. package/js/hooks/useCourseProducts.ts +4 -4
  18. package/js/hooks/useDefaultOrganizationId/index.tsx +4 -4
  19. package/js/hooks/useOffering/index.ts +32 -0
  20. package/js/hooks/useTeacherCoursesSearch/index.tsx +4 -4
  21. package/js/hooks/useTeacherPendingContractsCount/index.ts +4 -4
  22. package/js/pages/DashboardCourses/index.spec.tsx +17 -14
  23. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +11 -8
  24. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +6 -3
  25. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +11 -11
  26. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +10 -10
  27. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -4
  28. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +5 -5
  29. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +8 -8
  30. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +6 -6
  31. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +4 -4
  32. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +7 -7
  33. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +5 -5
  34. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +21 -21
  35. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +19 -13
  36. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +11 -11
  37. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +6 -6
  38. package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +6 -3
  39. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +16 -16
  40. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +4 -4
  41. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +7 -4
  42. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx +21 -21
  43. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.ts +5 -5
  44. package/js/pages/TeacherDashboardCourseLearnersLayout/index.spec.tsx +55 -55
  45. package/js/pages/TeacherDashboardCourseLearnersLayout/index.tsx +1 -1
  46. package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +11 -11
  47. package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +11 -11
  48. package/js/pages/TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx +7 -7
  49. package/js/pages/TeacherDashboardTraining/index.spec.tsx +25 -25
  50. package/js/pages/TeacherDashboardTraining/index.tsx +16 -12
  51. package/js/types/Joanie.ts +27 -20
  52. package/js/utils/test/factories/joanie.ts +14 -11
  53. package/js/utils/test/mockCourseProductWithOrder.ts +4 -4
  54. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +1 -1
  55. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
  56. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +3 -3
  57. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +1 -1
  58. package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +4 -4
  59. package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +1 -1
  60. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +23 -23
  61. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +4 -4
  62. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +20 -17
  63. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +22 -16
  64. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +4 -4
  65. package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +3 -3
  66. package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +4 -4
  67. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +14 -14
  68. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +105 -75
  69. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +6 -4
  70. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +27 -20
  71. package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +8 -8
  72. package/package.json +1 -1
  73. package/js/hooks/useOffer/index.ts +0 -32
@@ -97,21 +97,21 @@ describe('TeacherDashboardContractsLayout/ContractActionsBar', () => {
97
97
  {
98
98
  label: "doesn't have contract to download",
99
99
  hasContractToDownload: false,
100
- offerId: undefined,
100
+ offeringId: undefined,
101
101
  },
102
102
  {
103
- label: "doesn't have contract to download and offerId",
103
+ label: "doesn't have contract to download and offeringId",
104
104
  hasContractToDownload: false,
105
- offerId: faker.string.uuid(),
105
+ offeringId: faker.string.uuid(),
106
106
  },
107
- ])('should only display sign button when $label', ({ hasContractToDownload, offerId }) => {
107
+ ])('should only display sign button when $label', ({ hasContractToDownload, offeringId }) => {
108
108
  mockHasContractToDownload = hasContractToDownload;
109
109
  mockCanSignContracts = true;
110
110
  mockContractsToSignCount = 1;
111
111
 
112
112
  render(
113
113
  <Wrapper>
114
- <ContractActionsBar offerId={offerId} organizationId={faker.string.uuid()} />
114
+ <ContractActionsBar offeringId={offeringId} organizationId={faker.string.uuid()} />
115
115
  </Wrapper>,
116
116
  );
117
117
 
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Organization, Offer } from 'types/Joanie';
2
+ import { Organization, Offering } from 'types/Joanie';
3
3
  import useTeacherContractsToSign from 'pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign';
4
4
  import useHasContractToDownload from 'pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload';
5
5
  import SignOrganizationContractButton from '../SignOrganizationContractButton';
@@ -7,18 +7,18 @@ import BulkDownloadContractButton from '../BulkDownloadContractButton';
7
7
 
8
8
  interface ContractActionsProps {
9
9
  organizationId: Organization['id'];
10
- offerId?: Offer['id'];
10
+ offeringId?: Offering['id'];
11
11
  }
12
12
 
13
- const ContractActionsBar = ({ organizationId, offerId }: ContractActionsProps) => {
13
+ const ContractActionsBar = ({ organizationId, offeringId }: ContractActionsProps) => {
14
14
  const { canSignContracts, contractsToSignCount } = useTeacherContractsToSign({
15
15
  organizationId,
16
- offerId,
16
+ offeringId,
17
17
  });
18
- const hasContractToDownload = useHasContractToDownload(organizationId, offerId);
18
+ const hasContractToDownload = useHasContractToDownload(organizationId, offeringId);
19
19
 
20
20
  const nbAvailableActions = [canSignContracts, hasContractToDownload].filter((val) => val).length;
21
- const offerIds = offerId ? [offerId] : undefined;
21
+ const offeringIds = offeringId ? [offeringId] : undefined;
22
22
  return (
23
23
  nbAvailableActions > 0 && (
24
24
  <div
@@ -31,14 +31,14 @@ const ContractActionsBar = ({ organizationId, offerId }: ContractActionsProps) =
31
31
  {canSignContracts && (
32
32
  <div>
33
33
  <SignOrganizationContractButton
34
- offerIds={offerIds}
34
+ offeringIds={offeringIds}
35
35
  organizationId={organizationId}
36
36
  contractToSignCount={contractsToSignCount}
37
37
  />
38
38
  </div>
39
39
  )}
40
40
  {hasContractToDownload && (
41
- <BulkDownloadContractButton organizationId={organizationId} offerId={offerId} />
41
+ <BulkDownloadContractButton organizationId={organizationId} offeringId={offeringId} />
42
42
  )}
43
43
  </div>
44
44
  )
@@ -70,19 +70,19 @@ describe('TeacherDashboardContractsLayout/SignOrganizationContractButton', () =>
70
70
  {
71
71
  label: "organization's contracts",
72
72
  organizationId: faker.string.uuid(),
73
- offerIds: undefined,
73
+ offeringIds: undefined,
74
74
  },
75
75
  {
76
76
  label: "organization's training contracts",
77
77
  organizationId: faker.string.uuid(),
78
- offerIds: [faker.string.uuid()],
78
+ offeringIds: [faker.string.uuid()],
79
79
  },
80
- ])('should open $label frame on click', async ({ organizationId, offerIds }) => {
80
+ ])('should open $label frame on click', async ({ organizationId, offeringIds }) => {
81
81
  render(
82
82
  <Wrapper>
83
83
  <SignOrganizationContractButton
84
84
  organizationId={organizationId}
85
- offerIds={offerIds}
85
+ offeringIds={offeringIds}
86
86
  contractToSignCount={12}
87
87
  />
88
88
  </Wrapper>,
@@ -92,8 +92,8 @@ describe('TeacherDashboardContractsLayout/SignOrganizationContractButton', () =>
92
92
  const user = userEvent.setup();
93
93
 
94
94
  let getInvitationLinkUrl = `https://joanie.test/api/v1.0/organizations/${organizationId}/contracts-signature-link/`;
95
- if (offerIds) {
96
- getInvitationLinkUrl += `?offer_ids=${offerIds[0]}`;
95
+ if (offeringIds) {
96
+ getInvitationLinkUrl += `?offering_ids=${offeringIds[0]}`;
97
97
  }
98
98
 
99
99
  fetchMock.get(getInvitationLinkUrl, {
@@ -3,7 +3,7 @@ import { defineMessages, FormattedMessage } from 'react-intl';
3
3
  import { Button } from '@openfun/cunningham-react';
4
4
  import { OrganizationContractFrame } from 'components/ContractFrame';
5
5
 
6
- import { Offer, Organization } from 'types/Joanie';
6
+ import { Offering, Organization } from 'types/Joanie';
7
7
 
8
8
  const messages = defineMessages({
9
9
  signAllPendingContracts: {
@@ -14,7 +14,7 @@ const messages = defineMessages({
14
14
  });
15
15
 
16
16
  interface Props {
17
- offerIds?: Offer['id'][];
17
+ offeringIds?: Offering['id'][];
18
18
  organizationId: Organization['id'];
19
19
  contractToSignCount: number;
20
20
  }
@@ -22,7 +22,7 @@ interface Props {
22
22
  const SignOrganizationContractButton = ({
23
23
  organizationId,
24
24
  contractToSignCount,
25
- offerIds = [],
25
+ offeringIds = [],
26
26
  }: Props) => {
27
27
  const [contractFrameOpened, setContractFrameOpened] = useState(false);
28
28
  const hasContractToSign = contractToSignCount > 0;
@@ -48,7 +48,7 @@ const SignOrganizationContractButton = ({
48
48
  </Button>
49
49
  )}
50
50
  <OrganizationContractFrame
51
- offerIds={offerIds}
51
+ offeringIds={offeringIds}
52
52
  organizationId={organizationId}
53
53
  isOpen={contractFrameOpened}
54
54
  onClose={() => setContractFrameOpened(false)}
@@ -5,7 +5,7 @@ import { IntlProvider } from 'react-intl';
5
5
  import { PropsWithChildren } from 'react';
6
6
  import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
7
7
  import JoanieApiProvider from 'contexts/JoanieApiContext';
8
- import { OfferFactory, OrganizationFactory } from 'utils/test/factories/joanie';
8
+ import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
9
9
  import {
10
10
  LocalStorageArchiveFilters,
11
11
  storeContractArchiveId,
@@ -41,24 +41,24 @@ describe.each([
41
41
  {
42
42
  testLabel: 'for all organization and all trainings',
43
43
  organization: undefined,
44
- offer: undefined,
44
+ offering: undefined,
45
45
  },
46
46
  {
47
47
  testLabel: 'for a training in an organization',
48
48
  organization: OrganizationFactory().one(),
49
- offer: OfferFactory().one(),
49
+ offering: OfferingFactory().one(),
50
50
  },
51
51
  {
52
52
  testLabel: 'for an organization',
53
53
  organization: OrganizationFactory().one(),
54
- offer: undefined,
54
+ offering: undefined,
55
55
  },
56
56
  {
57
57
  testLabel: 'for a training',
58
58
  organization: undefined,
59
- offer: OfferFactory().one(),
59
+ offering: OfferingFactory().one(),
60
60
  },
61
- ])('useCheckContractArchiveExists $testLabel', ({ organization, offer }) => {
61
+ ])('useCheckContractArchiveExists $testLabel', ({ organization, offering }) => {
62
62
  const Wrapper = ({ children }: PropsWithChildren) => {
63
63
  return (
64
64
  <IntlProvider locale="en">
@@ -71,7 +71,7 @@ describe.each([
71
71
  beforeEach(() => {
72
72
  localStorageArchiveFilters = {
73
73
  organizationId: organization ? organization.id : undefined,
74
- offerId: offer ? offer.id : undefined,
74
+ offeringId: offering ? offering.id : undefined,
75
75
  };
76
76
 
77
77
  // Joanie providers calls
@@ -2,17 +2,17 @@ import { useEffect, useRef, useState } from 'react';
2
2
  import useContractArchive from 'hooks/useContractArchive';
3
3
  import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
4
4
  import { Nullable } from 'types/utils';
5
- import { Offer, Organization } from 'types/Joanie';
5
+ import { Offering, Organization } from 'types/Joanie';
6
6
  import { getStoredContractArchiveId } from '../useDownloadContractArchive/contractArchiveLocalStorage';
7
7
 
8
8
  export interface UseCheckContractArchiveExistsProps {
9
9
  organizationId?: Organization['id'];
10
- offerId?: Offer['id'];
10
+ offeringId?: Offering['id'];
11
11
  enable?: boolean;
12
12
  }
13
13
 
14
14
  const useCheckContractArchiveExist = (
15
- { organizationId, offerId, enable = true }: UseCheckContractArchiveExistsProps = {
15
+ { organizationId, offeringId, enable = true }: UseCheckContractArchiveExistsProps = {
16
16
  enable: true,
17
17
  },
18
18
  ) => {
@@ -55,7 +55,7 @@ const useCheckContractArchiveExist = (
55
55
  useEffect(() => {
56
56
  const storedContractArchiveId = getStoredContractArchiveId({
57
57
  organizationId,
58
- offerId,
58
+ offeringId,
59
59
  });
60
60
 
61
61
  if (enable && storedContractArchiveId) {
@@ -63,7 +63,7 @@ const useCheckContractArchiveExist = (
63
63
  } else {
64
64
  setIsContractArchiveExists(false);
65
65
  }
66
- }, [enable, organizationId, offerId]);
66
+ }, [enable, organizationId, offeringId]);
67
67
 
68
68
  // Be sure to clear any timeout before unmouting the hook.
69
69
  useEffect(() => {
@@ -1,6 +1,6 @@
1
1
  import { faker } from '@faker-js/faker';
2
2
  import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
3
- import { OfferFactory, 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
- offer: undefined,
17
+ offering: undefined,
18
18
  existingOrganization: undefined,
19
- existingOffer: undefined,
19
+ existingOffering: undefined,
20
20
  },
21
21
  {
22
22
  testLabel: 'for a training in an organization',
23
23
  organization: OrganizationFactory().one(),
24
- offer: OfferFactory().one(),
24
+ offering: OfferingFactory().one(),
25
25
  existingOrganization: undefined,
26
- existingOffer: undefined,
26
+ existingOffering: undefined,
27
27
  },
28
28
  {
29
29
  testLabel: 'for an organization',
30
30
  organization: OrganizationFactory().one(),
31
- offer: undefined,
31
+ offering: undefined,
32
32
  existingOrganization: undefined,
33
- existingOffer: undefined,
33
+ existingOffering: undefined,
34
34
  },
35
35
  {
36
36
  testLabel: 'for a training',
37
37
  organization: undefined,
38
- offer: OfferFactory().one(),
38
+ offering: OfferingFactory().one(),
39
39
  existingOrganization: undefined,
40
- existingOffer: 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
- offer: undefined,
45
+ offering: undefined,
46
46
  existingOrganization: OrganizationFactory().one(),
47
- existingOffer: OfferFactory().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
- offer: OfferFactory().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
- offer: undefined,
57
+ offering: undefined,
58
58
  existingOrganization: OrganizationFactory().one(),
59
- existingOffer: OfferFactory().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
- offer: OfferFactory().one(),
64
+ offering: OfferingFactory().one(),
65
65
  existingOrganization: OrganizationFactory().one(),
66
- existingOffer: OfferFactory().one(),
66
+ existingOffering: OfferingFactory().one(),
67
67
  },
68
68
 
69
69
  {
@@ -72,11 +72,11 @@ describe.each([
72
72
  {
73
73
  testLabel: 'Testing with a other id already stored',
74
74
  existingOrganization: OrganizationFactory().one(),
75
- existingOffer: OfferFactory().one(),
75
+ existingOffering: OfferingFactory().one(),
76
76
  },
77
77
  ])(
78
78
  'contractArchiveLocalStorage $testLabel',
79
- ({ organization, offer, existingOrganization, existingOffer }) => {
79
+ ({ organization, offering, existingOrganization, existingOffering }) => {
80
80
  let localStorageArchiveFilters: LocalStorageArchiveFilters;
81
81
  let localStorageExistingArchiveFilters: LocalStorageArchiveFilters;
82
82
  let exsitingContractId: string;
@@ -84,15 +84,15 @@ describe.each([
84
84
  beforeEach(() => {
85
85
  localStorageArchiveFilters = {
86
86
  organizationId: organization ? organization.id : undefined,
87
- offerId: offer ? offer.id : undefined,
87
+ offeringId: offering ? offering.id : undefined,
88
88
  };
89
89
  localStorageExistingArchiveFilters = {
90
90
  organizationId: existingOrganization ? existingOrganization.id : undefined,
91
- offerId: existingOffer ? existingOffer.id : undefined,
91
+ offeringId: existingOffering ? existingOffering.id : undefined,
92
92
  };
93
93
  exsitingContractId = faker.string.uuid();
94
94
 
95
- if (existingOffer && existingOrganization) {
95
+ if (existingOffering && existingOrganization) {
96
96
  // everything should work fine with multiple archive stored
97
97
  storeContractArchiveId({
98
98
  ...localStorageExistingArchiveFilters,
@@ -1,13 +1,16 @@
1
1
  import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
2
- import { Offer, Organization } from 'types/Joanie';
2
+ import { Offering, Organization } from 'types/Joanie';
3
3
 
4
4
  export interface LocalStorageArchiveFilters {
5
5
  organizationId?: Organization['id'];
6
- offerId?: Offer['id'];
6
+ offeringId?: Offering['id'];
7
7
  }
8
8
 
9
- const generateLocalStorageKey = ({ organizationId, offerId }: LocalStorageArchiveFilters = {}) => {
10
- return `${CONTRACT_DOWNLOAD_SETTINGS.contractArchiveLocalStorageKey}::${organizationId ?? 'all'}::${offerId ?? 'all'}`;
9
+ const generateLocalStorageKey = ({
10
+ organizationId,
11
+ offeringId,
12
+ }: LocalStorageArchiveFilters = {}) => {
13
+ return `${CONTRACT_DOWNLOAD_SETTINGS.contractArchiveLocalStorageKey}::${organizationId ?? 'all'}::${offeringId ?? 'all'}`;
11
14
  };
12
15
 
13
16
  const generateLocalStorageId = (contractArchiveId: string) => {
@@ -17,27 +20,30 @@ const generateLocalStorageId = (contractArchiveId: string) => {
17
20
  const storeContractArchiveId = ({
18
21
  contractArchiveId,
19
22
  organizationId,
20
- offerId,
23
+ offeringId,
21
24
  }: {
22
25
  contractArchiveId: string;
23
26
  organizationId?: Organization['id'];
24
- offerId?: Offer['id'];
27
+ offeringId?: Offering['id'];
25
28
  }) => {
26
29
  localStorage.setItem(
27
- generateLocalStorageKey({ organizationId, offerId }),
30
+ generateLocalStorageKey({ organizationId, offeringId }),
28
31
  generateLocalStorageId(contractArchiveId),
29
32
  );
30
33
  };
31
34
 
32
- const unstoreContractArchiveId = ({ organizationId, offerId }: LocalStorageArchiveFilters = {}) => {
33
- localStorage.removeItem(generateLocalStorageKey({ organizationId, offerId }));
35
+ const unstoreContractArchiveId = ({
36
+ organizationId,
37
+ offeringId,
38
+ }: LocalStorageArchiveFilters = {}) => {
39
+ localStorage.removeItem(generateLocalStorageKey({ organizationId, offeringId }));
34
40
  };
35
41
 
36
42
  const getStoredContractArchiveId = ({
37
43
  organizationId,
38
- offerId,
44
+ offeringId,
39
45
  }: LocalStorageArchiveFilters = {}) => {
40
- const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offerId }));
46
+ const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offeringId }));
41
47
  if (value === null) {
42
48
  return value;
43
49
  }
@@ -48,9 +54,9 @@ const getStoredContractArchiveId = ({
48
54
 
49
55
  const isStoredContractArchiveIdExpired = ({
50
56
  organizationId,
51
- offerId,
57
+ offeringId,
52
58
  }: LocalStorageArchiveFilters = {}) => {
53
- const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offerId }));
59
+ const value = localStorage.getItem(generateLocalStorageKey({ organizationId, offeringId }));
54
60
  if (value === null) {
55
61
  return false;
56
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 { OfferFactory, 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
- offer: undefined,
53
+ offering: undefined,
54
54
  },
55
55
  {
56
56
  testLabel: 'for a training in an organization',
57
57
  organization: OrganizationFactory().one(),
58
- offer: OfferFactory().one(),
58
+ offering: OfferingFactory().one(),
59
59
  },
60
60
  {
61
61
  testLabel: 'for an organization',
62
62
  organization: OrganizationFactory().one(),
63
- offer: undefined,
63
+ offering: undefined,
64
64
  },
65
65
  {
66
66
  testLabel: 'for a training',
67
67
  organization: undefined,
68
- offer: OfferFactory().one(),
68
+ offering: OfferingFactory().one(),
69
69
  },
70
- ])('useDownloadContractArchive $testLabel', ({ organization, offer }) => {
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
- offerId: offer ? offer.id : undefined,
76
+ offeringId: offering ? offering.id : undefined,
77
77
  };
78
78
  });
79
79
 
@@ -97,20 +97,20 @@ describe.each([
97
97
  {
98
98
  testLabel: 'Testing with a other id already stored',
99
99
  existingOrganization: OrganizationFactory().one(),
100
- existingOffer: OfferFactory().one(),
100
+ existingOffering: OfferingFactory().one(),
101
101
  },
102
- ])('$testLabel', ({ existingOrganization, existingOffer }) => {
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
- offerId: existingOffer ? existingOffer.id : undefined,
109
+ offeringId: existingOffering ? existingOffering.id : undefined,
110
110
  };
111
111
  exsitingContractId = faker.string.uuid();
112
112
 
113
- if (existingOffer && existingOrganization) {
113
+ if (existingOffering && existingOrganization) {
114
114
  // everything should work fine with multiple archive stored
115
115
  storeContractArchiveId({
116
116
  ...localStorageExistingArchiveFilters,
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useState } from 'react';
2
2
  import useContractArchive from 'hooks/useContractArchive';
3
- import { Offer, 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
- offerId?: Offer['id'];
22
+ offeringId?: Offering['id'];
23
23
  }
24
24
 
25
25
  const useDownloadContractArchive = ({
26
26
  organizationId,
27
- offerId,
27
+ offeringId,
28
28
  }: UseTeacherContractsBulkDownloadProps) => {
29
29
  const localstorageArchiveFilters = {
30
30
  organizationId,
31
- offerId,
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, offerId);
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, offerId);
119
+ newContractArchiveId = await createArchive(organizationId, offeringId);
120
120
  setContractArchiveId(newContractArchiveId);
121
121
  storeContractArchiveId({
122
122
  ...localstorageArchiveFilters,
@@ -1,14 +1,17 @@
1
1
  import { useOrganizationContracts } from 'hooks/useContracts';
2
2
  import { PER_PAGE } from 'settings';
3
- import { ContractState, Offer, Organization } from 'types/Joanie';
3
+ import { ContractState, Offering, Organization } from 'types/Joanie';
4
4
 
5
- const useHasContractToDownload = (organizationId?: Organization['id'], offerId?: Offer['id']) => {
5
+ const useHasContractToDownload = (
6
+ organizationId?: Organization['id'],
7
+ offeringId?: Offering['id'],
8
+ ) => {
6
9
  const {
7
10
  items: contracts,
8
11
  states: { isFetched },
9
12
  } = useOrganizationContracts({
10
13
  organization_id: organizationId,
11
- offer_id: offerId,
14
+ offering_id: offeringId,
12
15
  signature_state: ContractState.SIGNED,
13
16
  page: 1,
14
17
  page_size: PER_PAGE.teacherContractList,