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
@@ -3,11 +3,7 @@ import { screen } from '@testing-library/react';
3
3
  import { getAllByRole } from '@testing-library/dom';
4
4
  import userEvent from '@testing-library/user-event';
5
5
  import { RichieContextFactory as mockRichieContextFactory } from 'utils/test/factories/richie';
6
- import {
7
- ContractFactory,
8
- CourseProductRelationFactory,
9
- OrganizationFactory,
10
- } from 'utils/test/factories/joanie';
6
+ import { ContractFactory, OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
11
7
  import { expectNoSpinner } from 'utils/test/expectSpinner';
12
8
  import { expectBannerError } from 'utils/test/expectBanner';
13
9
  import { HttpStatusCode } from 'utils/errors/HttpError';
@@ -37,8 +33,8 @@ jest.mock('components/ContractFrame', () => ({
37
33
  describe('pages/TeacherDashboardContracts', () => {
38
34
  setupJoanieSession();
39
35
 
40
- it('should render a list of contracts for a course product relation', async () => {
41
- const courseProductRelation = CourseProductRelationFactory().one();
36
+ it('should render a list of contracts for an offering', async () => {
37
+ const offering = OfferingFactory().one();
42
38
  const contracts = ContractFactory({
43
39
  student_signed_on: Date.toString(),
44
40
  organization_signed_on: Date.toString(),
@@ -48,31 +44,32 @@ describe('pages/TeacherDashboardContracts', () => {
48
44
 
49
45
  // OrganizationContractFilter request all organizations forwho the user have access
50
46
  fetchMock.get(
51
- `https://joanie.endpoint/api/v1.0/organizations/?course_product_relation_id=${courseProductRelation.id}`,
47
+ `https://joanie.endpoint/api/v1.0/organizations/?offering_id=${offering.id}`,
52
48
  organizations,
53
49
  );
54
50
  // TeacherDashboardContracts request a paginated list of contracts to display
55
51
  fetchMock.get(
56
- `https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?course_product_relation_id=${courseProductRelation.id}&signature_state=signed&page=1&page_size=25`,
52
+ `https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/` +
53
+ `contracts/?offering_id=${offering.id}&signature_state=signed&page=1&page_size=25`,
57
54
  { results: contracts, count: 0, previous: null, next: null },
58
55
  );
59
56
  // useTeacherContractsToSign request all contract to sign, without pagination
60
57
  fetchMock.get(
61
- `https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/contracts/?signature_state=half_signed&course_product_relation_id=${courseProductRelation.id}`,
58
+ `https://joanie.endpoint/api/v1.0/organizations/${defaultOrganization.id}/` +
59
+ `contracts/?signature_state=half_signed&offering_id=${offering.id}`,
62
60
  { results: [], count: 0, previous: null, next: null },
63
61
  );
64
62
 
65
63
  render(<TeacherDashboardContracts />, {
66
64
  routerOptions: {
67
- path: '/courses/:courseId/products/:courseProductRelationId/contracts',
68
- initialEntries: [
69
- `/courses/${courseProductRelation.course.id}/products/${courseProductRelation.id}/contracts`,
70
- ],
65
+ path: '/courses/:courseId/products/:offeringId/contracts',
66
+ initialEntries: [`/courses/${offering.course.id}/products/${offering.id}/contracts`],
71
67
  },
72
68
  });
73
69
 
74
70
  await expectNoSpinner();
75
71
 
72
+ // screen.logTestingPlaygroundURL();
76
73
  // Organization filter should have been rendered
77
74
  const organizationFilter: HTMLInputElement = await screen.findByRole('combobox', {
78
75
  name: 'Organization',
@@ -42,20 +42,15 @@ const TeacherDashboardContracts = () => {
42
42
  defaultPage: page ? parseInt(page, 10) : 1,
43
43
  pageSize: PER_PAGE.teacherContractList,
44
44
  });
45
- const {
46
- organizationId: routeOrganizationId,
47
- courseProductRelationId: routeCourseProductRelationId,
48
- } = useParams<TeacherDashboardContractsParams>();
45
+ const { organizationId: routeOrganizationId, offeringId: routeOfferingId } =
46
+ useParams<TeacherDashboardContractsParams>();
49
47
  // organization list is used to show/hide organization filter.
50
48
  // when organizationId is in route's params this filter is always hidden.
51
49
  // therefore we don't need to enable this query.
52
50
  const {
53
51
  items: organizationList,
54
52
  states: { isFetched: isOrganizationListFetched },
55
- } = useOrganizations(
56
- { course_product_relation_id: routeCourseProductRelationId },
57
- { enabled: !routeOrganizationId },
58
- );
53
+ } = useOrganizations({ offering_id: routeOfferingId }, { enabled: !routeOrganizationId });
59
54
  const hasMultipleOrganizations = isOrganizationListFetched && organizationList.length > 1;
60
55
  const { initialFilters, filters, setFilters } = useTeacherContractFilters();
61
56
  const {
@@ -98,7 +93,7 @@ const TeacherDashboardContracts = () => {
98
93
  <div className="dashboard__page__actions">
99
94
  <ContractActionsBar
100
95
  organizationId={filters.organization_id!}
101
- courseProductRelationId={filters.course_product_relation_id}
96
+ offeringId={filters.offering_id}
102
97
  />
103
98
  <ContractFiltersBar
104
99
  defaultValues={initialFilters}
@@ -9,7 +9,7 @@ import JoanieApiProvider from 'contexts/JoanieApiContext';
9
9
  import { createTestQueryClient } from 'utils/test/createTestQueryClient';
10
10
  import { ContractDownloadStatus } from 'pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive';
11
11
 
12
- import { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
12
+ import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
13
13
  import { unstoreContractArchiveId } from 'pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage';
14
14
  import BulkDownloadContractButton from '.';
15
15
 
@@ -44,26 +44,26 @@ describe.each([
44
44
  {
45
45
  testLabel: 'for all organization and all trainings',
46
46
  organization: undefined,
47
- courseProductRelation: undefined,
47
+ offering: undefined,
48
48
  },
49
49
  {
50
50
  testLabel: 'for a training in an organization',
51
51
  organization: OrganizationFactory().one(),
52
- courseProductRelation: CourseProductRelationFactory().one(),
52
+ offering: OfferingFactory().one(),
53
53
  },
54
54
  {
55
55
  testLabel: 'for an organization',
56
56
  organization: OrganizationFactory().one(),
57
- courseProductRelation: undefined,
57
+ offering: undefined,
58
58
  },
59
59
  {
60
60
  testLabel: 'for a training',
61
61
  organization: undefined,
62
- courseProductRelation: CourseProductRelationFactory().one(),
62
+ offering: OfferingFactory().one(),
63
63
  },
64
64
  ])(
65
65
  'TeacherDashboardContractsLayout/BulkDownloadContractButton $testLabel',
66
- ({ organization, courseProductRelation }) => {
66
+ ({ organization, offering }) => {
67
67
  const Wrapper = ({ children }: PropsWithChildren) => {
68
68
  return (
69
69
  <IntlProvider locale="en">
@@ -86,7 +86,7 @@ describe.each([
86
86
  jest.resetAllMocks();
87
87
  unstoreContractArchiveId({
88
88
  organizationId: organization ? organization.id : undefined,
89
- courseProductRelationId: courseProductRelation ? courseProductRelation.id : undefined,
89
+ offeringId: offering ? offering.id : undefined,
90
90
  });
91
91
  });
92
92
 
@@ -97,7 +97,7 @@ describe.each([
97
97
  <Wrapper>
98
98
  <BulkDownloadContractButton
99
99
  organizationId={organization?.id ?? undefined}
100
- courseProductRelationId={courseProductRelation?.id ?? undefined}
100
+ offeringId={offering?.id ?? undefined}
101
101
  />
102
102
  </Wrapper>,
103
103
  );
@@ -118,7 +118,7 @@ describe.each([
118
118
  <Wrapper>
119
119
  <BulkDownloadContractButton
120
120
  organizationId={organization?.id ?? undefined}
121
- courseProductRelationId={courseProductRelation?.id ?? undefined}
121
+ offeringId={offering?.id ?? undefined}
122
122
  />
123
123
  </Wrapper>,
124
124
  );
@@ -139,7 +139,7 @@ describe.each([
139
139
  <Wrapper>
140
140
  <BulkDownloadContractButton
141
141
  organizationId={organization?.id ?? undefined}
142
- courseProductRelationId={courseProductRelation?.id ?? undefined}
142
+ offeringId={offering?.id ?? undefined}
143
143
  />
144
144
  </Wrapper>,
145
145
  );
@@ -160,7 +160,7 @@ describe.each([
160
160
  <Wrapper>
161
161
  <BulkDownloadContractButton
162
162
  organizationId={organization?.id ?? undefined}
163
- courseProductRelationId={courseProductRelation?.id ?? undefined}
163
+ offeringId={offering?.id ?? undefined}
164
164
  />
165
165
  </Wrapper>,
166
166
  );
@@ -14,7 +14,7 @@ import {
14
14
  unstoreContractArchiveId,
15
15
  } from 'pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage';
16
16
  import { CONTRACT_DOWNLOAD_SETTINGS } from 'settings';
17
- import { CourseProductRelationFactory, OrganizationFactory } from 'utils/test/factories/joanie';
17
+ import { OfferingFactory, OrganizationFactory } from 'utils/test/factories/joanie';
18
18
  import BulkDownloadContractButton from '.';
19
19
 
20
20
  jest.mock('utils/context', () => ({
@@ -45,26 +45,26 @@ describe.each([
45
45
  {
46
46
  testLabel: 'for all organization and all trainings',
47
47
  organization: undefined,
48
- courseProductRelation: undefined,
48
+ offering: undefined,
49
49
  },
50
50
  {
51
51
  testLabel: 'for a training in an organization',
52
52
  organization: OrganizationFactory().one(),
53
- courseProductRelation: CourseProductRelationFactory().one(),
53
+ offering: OfferingFactory().one(),
54
54
  },
55
55
  {
56
56
  testLabel: 'for an organization',
57
57
  organization: OrganizationFactory().one(),
58
- courseProductRelation: undefined,
58
+ offering: undefined,
59
59
  },
60
60
  {
61
61
  testLabel: 'for a training',
62
62
  organization: undefined,
63
- courseProductRelation: CourseProductRelationFactory().one(),
63
+ offering: OfferingFactory().one(),
64
64
  },
65
65
  ])(
66
66
  'TeacherDashboardContractsLayout/BulkDownloadContractButton with fake timer, $testLabel',
67
- ({ organization, courseProductRelation }) => {
67
+ ({ organization, offering }) => {
68
68
  let localStorageArchiveFilters: LocalStorageArchiveFilters;
69
69
 
70
70
  const Wrapper = ({ children }: PropsWithChildren) => {
@@ -81,7 +81,7 @@ describe.each([
81
81
  beforeEach(() => {
82
82
  localStorageArchiveFilters = {
83
83
  organizationId: organization ? organization.id : undefined,
84
- courseProductRelationId: courseProductRelation ? courseProductRelation.id : undefined,
84
+ offeringId: offering ? offering.id : undefined,
85
85
  };
86
86
  mockHasContractToDownload = true;
87
87
 
@@ -102,7 +102,7 @@ describe.each([
102
102
  jest.clearAllMocks();
103
103
  unstoreContractArchiveId({
104
104
  organizationId: organization ? organization.id : undefined,
105
- courseProductRelationId: courseProductRelation ? courseProductRelation.id : undefined,
105
+ offeringId: offering ? offering.id : undefined,
106
106
  });
107
107
  });
108
108
 
@@ -114,7 +114,7 @@ describe.each([
114
114
  <Wrapper>
115
115
  <BulkDownloadContractButton
116
116
  organizationId={organization?.id ?? undefined}
117
- courseProductRelationId={courseProductRelation?.id ?? undefined}
117
+ offeringId={offering?.id ?? undefined}
118
118
  />
119
119
  </Wrapper>,
120
120
  );
@@ -151,10 +151,7 @@ describe.each([
151
151
 
152
152
  render(
153
153
  <Wrapper>
154
- <BulkDownloadContractButton
155
- organizationId={organization?.id}
156
- courseProductRelationId={courseProductRelation?.id}
157
- />
154
+ <BulkDownloadContractButton organizationId={organization?.id} offeringId={offering?.id} />
158
155
  </Wrapper>,
159
156
  );
160
157
 
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
4
4
  import useDownloadContractArchive, {
5
5
  ContractDownloadStatus,
6
6
  } from 'pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive';
7
- import { CourseProductRelation, Organization } from 'types/Joanie';
7
+ import { Offering, Organization } from 'types/Joanie';
8
8
 
9
9
  const messages = defineMessages({
10
10
  bulkDownloadButtonDownloadLabel: {
@@ -26,16 +26,16 @@ const messages = defineMessages({
26
26
 
27
27
  interface BulkDownloadContractButtonProps {
28
28
  organizationId?: Organization['id'];
29
- courseProductRelationId?: CourseProductRelation['id'];
29
+ offeringId?: Offering['id'];
30
30
  }
31
31
 
32
32
  const BulkDownloadContractButton = ({
33
33
  organizationId,
34
- courseProductRelationId,
34
+ offeringId,
35
35
  }: BulkDownloadContractButtonProps) => {
36
36
  const { downloadContractArchive, createContractArchive, status } = useDownloadContractArchive({
37
37
  organizationId,
38
- courseProductRelationId,
38
+ offeringId,
39
39
  });
40
40
 
41
41
  useEffect(() => {
@@ -97,38 +97,30 @@ describe('TeacherDashboardContractsLayout/ContractActionsBar', () => {
97
97
  {
98
98
  label: "doesn't have contract to download",
99
99
  hasContractToDownload: false,
100
- courseProductRelationId: undefined,
100
+ offeringId: undefined,
101
101
  },
102
102
  {
103
- label: "doesn't have contract to download and courseProductRelationId",
103
+ label: "doesn't have contract to download and offeringId",
104
104
  hasContractToDownload: false,
105
- courseProductRelationId: faker.string.uuid(),
105
+ offeringId: faker.string.uuid(),
106
106
  },
107
- ])(
108
- 'should only display sign button when $label',
109
- ({ hasContractToDownload, courseProductRelationId }) => {
110
- mockHasContractToDownload = hasContractToDownload;
111
- mockCanSignContracts = true;
112
- mockContractsToSignCount = 1;
113
-
114
- render(
115
- <Wrapper>
116
- <ContractActionsBar
117
- courseProductRelationId={courseProductRelationId}
118
- organizationId={faker.string.uuid()}
119
- />
120
- </Wrapper>,
121
- );
122
-
123
- expect(screen.getByTestId('teacher-contracts-list-actionsBar')).toBeInTheDocument();
124
- expect(
125
- screen.getByRole('button', { name: /Sign all pending contracts/ }),
126
- ).toBeInTheDocument();
127
- expect(
128
- screen.queryByRole('button', { name: /Request contracts archive/ }),
129
- ).not.toBeInTheDocument();
130
- },
131
- );
107
+ ])('should only display sign button when $label', ({ hasContractToDownload, offeringId }) => {
108
+ mockHasContractToDownload = hasContractToDownload;
109
+ mockCanSignContracts = true;
110
+ mockContractsToSignCount = 1;
111
+
112
+ render(
113
+ <Wrapper>
114
+ <ContractActionsBar offeringId={offeringId} organizationId={faker.string.uuid()} />
115
+ </Wrapper>,
116
+ );
117
+
118
+ expect(screen.getByTestId('teacher-contracts-list-actionsBar')).toBeInTheDocument();
119
+ expect(screen.getByRole('button', { name: /Sign all pending contracts/ })).toBeInTheDocument();
120
+ expect(
121
+ screen.queryByRole('button', { name: /Request contracts archive/ }),
122
+ ).not.toBeInTheDocument();
123
+ });
132
124
 
133
125
  it("shouldn't only display download button", () => {
134
126
  mockHasContractToDownload = true;
@@ -1,5 +1,5 @@
1
1
  import classNames from 'classnames';
2
- import { Organization, CourseProductRelation } 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
- courseProductRelationId?: CourseProductRelation['id'];
10
+ offeringId?: Offering['id'];
11
11
  }
12
12
 
13
- const ContractActionsBar = ({ organizationId, courseProductRelationId }: ContractActionsProps) => {
13
+ const ContractActionsBar = ({ organizationId, offeringId }: ContractActionsProps) => {
14
14
  const { canSignContracts, contractsToSignCount } = useTeacherContractsToSign({
15
15
  organizationId,
16
- courseProductRelationId,
16
+ offeringId,
17
17
  });
18
- const hasContractToDownload = useHasContractToDownload(organizationId, courseProductRelationId);
18
+ const hasContractToDownload = useHasContractToDownload(organizationId, offeringId);
19
19
 
20
20
  const nbAvailableActions = [canSignContracts, hasContractToDownload].filter((val) => val).length;
21
- const courseProductRelationIds = courseProductRelationId ? [courseProductRelationId] : undefined;
21
+ const offeringIds = offeringId ? [offeringId] : undefined;
22
22
  return (
23
23
  nbAvailableActions > 0 && (
24
24
  <div
@@ -31,17 +31,14 @@ const ContractActionsBar = ({ organizationId, courseProductRelationId }: Contrac
31
31
  {canSignContracts && (
32
32
  <div>
33
33
  <SignOrganizationContractButton
34
- courseProductRelationIds={courseProductRelationIds}
34
+ offeringIds={offeringIds}
35
35
  organizationId={organizationId}
36
36
  contractToSignCount={contractsToSignCount}
37
37
  />
38
38
  </div>
39
39
  )}
40
40
  {hasContractToDownload && (
41
- <BulkDownloadContractButton
42
- organizationId={organizationId}
43
- courseProductRelationId={courseProductRelationId}
44
- />
41
+ <BulkDownloadContractButton organizationId={organizationId} offeringId={offeringId} />
45
42
  )}
46
43
  </div>
47
44
  )
@@ -70,19 +70,19 @@ describe('TeacherDashboardContractsLayout/SignOrganizationContractButton', () =>
70
70
  {
71
71
  label: "organization's contracts",
72
72
  organizationId: faker.string.uuid(),
73
- courseProductRelationIds: undefined,
73
+ offeringIds: undefined,
74
74
  },
75
75
  {
76
76
  label: "organization's training contracts",
77
77
  organizationId: faker.string.uuid(),
78
- courseProductRelationIds: [faker.string.uuid()],
78
+ offeringIds: [faker.string.uuid()],
79
79
  },
80
- ])('should open $label frame on click', async ({ organizationId, courseProductRelationIds }) => {
80
+ ])('should open $label frame on click', async ({ organizationId, offeringIds }) => {
81
81
  render(
82
82
  <Wrapper>
83
83
  <SignOrganizationContractButton
84
84
  organizationId={organizationId}
85
- courseProductRelationIds={courseProductRelationIds}
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 (courseProductRelationIds) {
96
- getInvitationLinkUrl += `?course_product_relation_ids=${courseProductRelationIds[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 { CourseProductRelation, 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
- courseProductRelationIds?: CourseProductRelation['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
- courseProductRelationIds = [],
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
- courseProductRelationIds={courseProductRelationIds}
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 { CourseProductRelationFactory, 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
- courseProductRelation: undefined,
44
+ offering: undefined,
45
45
  },
46
46
  {
47
47
  testLabel: 'for a training in an organization',
48
48
  organization: OrganizationFactory().one(),
49
- courseProductRelation: CourseProductRelationFactory().one(),
49
+ offering: OfferingFactory().one(),
50
50
  },
51
51
  {
52
52
  testLabel: 'for an organization',
53
53
  organization: OrganizationFactory().one(),
54
- courseProductRelation: undefined,
54
+ offering: undefined,
55
55
  },
56
56
  {
57
57
  testLabel: 'for a training',
58
58
  organization: undefined,
59
- courseProductRelation: CourseProductRelationFactory().one(),
59
+ offering: OfferingFactory().one(),
60
60
  },
61
- ])('useCheckContractArchiveExists $testLabel', ({ organization, courseProductRelation }) => {
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
- courseProductRelationId: courseProductRelation ? courseProductRelation.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 { CourseProductRelation, 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
- courseProductRelationId?: CourseProductRelation['id'];
10
+ offeringId?: Offering['id'];
11
11
  enable?: boolean;
12
12
  }
13
13
 
14
14
  const useCheckContractArchiveExist = (
15
- { organizationId, courseProductRelationId, 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
- courseProductRelationId,
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, courseProductRelationId]);
66
+ }, [enable, organizationId, offeringId]);
67
67
 
68
68
  // Be sure to clear any timeout before unmouting the hook.
69
69
  useEffect(() => {