richie-education 3.1.3-dev8 → 3.2.1-dev1

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 (115) hide show
  1. package/.storybook/__mocks__/utils/context.ts +4 -0
  2. package/i18n/locales/ar-SA.json +30 -10
  3. package/i18n/locales/es-ES.json +30 -10
  4. package/i18n/locales/fa-IR.json +30 -10
  5. package/i18n/locales/fr-CA.json +31 -11
  6. package/i18n/locales/fr-FR.json +32 -12
  7. package/i18n/locales/ko-KR.json +30 -10
  8. package/i18n/locales/pt-PT.json +30 -10
  9. package/i18n/locales/ru-RU.json +30 -10
  10. package/i18n/locales/vi-VN.json +30 -10
  11. package/js/api/joanie.ts +8 -8
  12. package/js/components/ContractFrame/OrganizationContractFrame.spec.tsx +11 -19
  13. package/js/components/ContractFrame/OrganizationContractFrame.tsx +4 -4
  14. package/js/components/CourseGlimpse/CourseGlimpseFooter.tsx +30 -5
  15. package/js/components/CourseGlimpse/index.spec.tsx +18 -0
  16. package/js/components/CourseGlimpse/index.stories.tsx +75 -4
  17. package/js/components/CourseGlimpse/index.tsx +4 -0
  18. package/js/components/CourseGlimpse/utils.ts +35 -30
  19. package/js/components/CourseGlimpseList/utils.ts +2 -2
  20. package/js/components/PurchaseButton/index.tsx +3 -3
  21. package/js/components/SaleTunnel/GenericSaleTunnel.tsx +6 -3
  22. package/js/components/SaleTunnel/SaleTunnelInformation/index.tsx +9 -7
  23. package/js/components/SaleTunnel/index.full-process.spec.tsx +3 -3
  24. package/js/components/SaleTunnel/index.spec.tsx +131 -64
  25. package/js/components/SaleTunnel/index.stories.tsx +17 -2
  26. package/js/components/SaleTunnel/index.tsx +2 -2
  27. package/js/components/TeacherDashboardCourseList/index.spec.tsx +3 -3
  28. package/js/components/TeacherDashboardCourseList/index.tsx +2 -2
  29. package/js/hooks/useContractArchive/index.ts +3 -3
  30. package/js/hooks/useCourseProductUnion/index.spec.tsx +16 -18
  31. package/js/hooks/useCourseProductUnion/index.ts +7 -7
  32. package/js/hooks/useCourseProducts.ts +4 -8
  33. package/js/hooks/useDefaultOrganizationId/index.tsx +4 -7
  34. package/js/hooks/useOffering/index.ts +32 -0
  35. package/js/hooks/useTeacherCoursesSearch/index.tsx +2 -2
  36. package/js/hooks/useTeacherPendingContractsCount/index.ts +4 -4
  37. package/js/pages/DashboardCourses/index.spec.tsx +14 -14
  38. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.spec.tsx +11 -14
  39. package/js/pages/TeacherDashboardContractsLayout/TeacherDashboardContracts/index.tsx +4 -9
  40. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.spec.tsx +11 -11
  41. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.timer.spec.tsx +10 -13
  42. package/js/pages/TeacherDashboardContractsLayout/components/BulkDownloadContractButton/index.tsx +4 -4
  43. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.spec.tsx +20 -28
  44. package/js/pages/TeacherDashboardContractsLayout/components/ContractActionsBar/index.tsx +8 -11
  45. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.spec.tsx +6 -6
  46. package/js/pages/TeacherDashboardContractsLayout/components/SignOrganizationContractButton/index.tsx +4 -4
  47. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.spec.tsx +7 -7
  48. package/js/pages/TeacherDashboardContractsLayout/hooks/useCheckContractArchiveExists/index.tsx +5 -5
  49. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.spec.ts +21 -28
  50. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/contractArchiveLocalStorage.ts +13 -17
  51. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.spec.tsx +11 -13
  52. package/js/pages/TeacherDashboardContractsLayout/hooks/useDownloadContractArchive/index.tsx +6 -6
  53. package/js/pages/TeacherDashboardContractsLayout/hooks/useHasContractToDownload/index.tsx +3 -3
  54. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.spec.tsx +16 -16
  55. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractFilters/index.tsx +4 -4
  56. package/js/pages/TeacherDashboardContractsLayout/hooks/useTeacherContractsToSign.tsx +4 -4
  57. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.spec.tsx +21 -21
  58. package/js/pages/TeacherDashboardCourseLearnersLayout/hooks/useCourseLearnersFilters/index.ts +5 -10
  59. package/js/pages/TeacherDashboardCourseLearnersLayout/index.spec.tsx +61 -79
  60. package/js/pages/TeacherDashboardCourseLearnersLayout/index.tsx +1 -1
  61. package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +11 -11
  62. package/js/pages/TeacherDashboardOrganizationCourseLoader/index.spec.tsx +11 -11
  63. package/js/pages/TeacherDashboardTraining/TeacherDashboardTrainingLoader.tsx +7 -7
  64. package/js/pages/TeacherDashboardTraining/index.spec.tsx +21 -29
  65. package/js/pages/TeacherDashboardTraining/index.tsx +12 -16
  66. package/js/settings/index.ts +1 -0
  67. package/js/settings/settings.prod.ts +1 -0
  68. package/js/translations/ar-SA.json +1 -1
  69. package/js/translations/es-ES.json +1 -1
  70. package/js/translations/fa-IR.json +1 -1
  71. package/js/translations/fr-CA.json +1 -1
  72. package/js/translations/fr-FR.json +1 -1
  73. package/js/translations/ko-KR.json +1 -1
  74. package/js/translations/pt-PT.json +1 -1
  75. package/js/translations/ru-RU.json +1 -1
  76. package/js/translations/vi-VN.json +1 -1
  77. package/js/types/Course.ts +4 -0
  78. package/js/types/Joanie.ts +31 -22
  79. package/js/types/index.ts +6 -2
  80. package/js/utils/test/factories/joanie.ts +18 -11
  81. package/js/utils/test/factories/richie.ts +10 -2
  82. package/js/utils/test/mockCourseProductWithOrder.ts +4 -4
  83. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/DashboardItemEnrollment.tsx +1 -1
  84. package/js/widgets/Dashboard/components/DashboardItem/Enrollment/ProductCertificateFooter/index.spec.tsx +1 -1
  85. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrder.tsx +3 -3
  86. package/js/widgets/Dashboard/components/DashboardItem/Order/DashboardItemOrderContract.useUnionResource.cache.spec.tsx +1 -1
  87. package/js/widgets/Dashboard/components/DashboardItem/Order/Installment/index.tsx +4 -4
  88. package/js/widgets/Dashboard/components/DashboardItem/stories.mock.ts +1 -1
  89. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.spec.tsx +23 -28
  90. package/js/widgets/Dashboard/components/DashboardSidebar/components/ContractNavLink/index.tsx +4 -8
  91. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.spec.tsx +17 -24
  92. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/index.tsx +18 -21
  93. package/js/widgets/Dashboard/components/TeacherDashboardCourseSidebar/utils.ts +4 -4
  94. package/js/widgets/Dashboard/components/TeacherDashboardOrganizationSidebar/index.tsx +3 -7
  95. package/js/widgets/Dashboard/utils/teacherDashboardPaths.tsx +4 -4
  96. package/js/widgets/Slider/components/SlidePanel.tsx +9 -0
  97. package/js/widgets/Slider/index.stories.tsx +53 -0
  98. package/js/widgets/Slider/index.tsx +21 -2
  99. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/CourseProductItemFooter/index.tsx +10 -14
  100. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/_styles.scss +8 -1
  101. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/CourseRunList.tsx +2 -2
  102. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/components/CourseProductCourseRuns/_styles.scss +9 -0
  103. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.spec.tsx +116 -75
  104. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.stories.tsx +6 -4
  105. package/js/widgets/SyllabusCourseRunsList/components/CourseProductItem/index.tsx +29 -30
  106. package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRun/index.stories.tsx +81 -0
  107. package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRun/index.tsx +36 -2
  108. package/js/widgets/SyllabusCourseRunsList/components/SyllabusCourseRunCompacted/index.tsx +36 -2
  109. package/js/widgets/SyllabusCourseRunsList/index.spec.tsx +58 -8
  110. package/package.json +2 -1
  111. package/scss/colors/_theme.scss +3 -0
  112. package/scss/components/templates/richie/slider/_slider.scss +19 -0
  113. package/scss/objects/_blogpost_glimpses.scss +5 -0
  114. package/scss/objects/_course_glimpses.scss +16 -0
  115. package/js/hooks/useCourseProductRelation/index.ts +0 -44
@@ -1,7 +1,7 @@
1
1
  import { Children, useEffect, useMemo } from 'react';
2
2
  import { defineMessages, FormattedMessage, FormattedNumber, useIntl } from 'react-intl';
3
3
  import c from 'classnames';
4
- import { CourseProductRelation, CredentialOrder, Product, ProductType } from 'types/Joanie';
4
+ import { Offering, CredentialOrder, Product, ProductType } from 'types/Joanie';
5
5
  import { useCourseProduct } from 'hooks/useCourseProducts';
6
6
  import { Spinner } from 'components/Spinner';
7
7
  import { Icon, IconTypeEnum } from 'components/Icon';
@@ -77,16 +77,9 @@ type HeaderProps = {
77
77
  canPurchase: boolean;
78
78
  order: Maybe<CredentialOrder>;
79
79
  product: Product;
80
- courseProductRelation: CourseProductRelation;
80
+ offering: Offering;
81
81
  };
82
- const Header = ({
83
- product,
84
- order,
85
- courseProductRelation,
86
- hasPurchased,
87
- canPurchase,
88
- compact,
89
- }: HeaderProps) => {
82
+ const Header = ({ product, order, offering, hasPurchased, canPurchase, compact }: HeaderProps) => {
90
83
  const intl = useIntl();
91
84
  const formatDate = useDateFormat();
92
85
 
@@ -110,7 +103,7 @@ const Header = ({
110
103
  return null;
111
104
  }
112
105
 
113
- if (courseProductRelation.discounted_price) {
106
+ if (offering?.rules?.discounted_price != null) {
114
107
  return (
115
108
  <>
116
109
  <span id="original-price" className="offscreen">
@@ -129,7 +122,7 @@ const Header = ({
129
122
  <ins aria-describedby="discount-price" className="product-widget__price-discount">
130
123
  <FormattedNumber
131
124
  currency={product.price_currency}
132
- value={courseProductRelation.discounted_price}
125
+ value={offering.rules.discounted_price}
133
126
  style="currency"
134
127
  />
135
128
  </ins>
@@ -140,7 +133,7 @@ const Header = ({
140
133
  return (
141
134
  <FormattedNumber currency={product.price_currency} value={product.price} style="currency" />
142
135
  );
143
- }, [canPurchase, courseProductRelation.discounted_price, product.price]);
136
+ }, [canPurchase, offering?.rules?.discounted_price, product.price]);
144
137
 
145
138
  return (
146
139
  <header className="product-widget__header">
@@ -151,39 +144,39 @@ const Header = ({
151
144
  {hasPurchased && <FormattedMessage {...messages.purchased} />}
152
145
  {displayPrice}
153
146
  </strong>
154
- {courseProductRelation?.description && (
155
- <p className="product-widget__header-description">{courseProductRelation.description}</p>
147
+ {offering?.rules?.description && (
148
+ <p className="product-widget__header-description">{offering.rules.description}</p>
156
149
  )}
157
- {courseProductRelation?.discounted_price && (
150
+ {offering?.rules?.discounted_price && (
158
151
  <p className="product-widget__header-discount">
159
- {courseProductRelation.discount_rate ? (
152
+ {offering.rules.discount_rate ? (
160
153
  <span className="product-widget__header-discount-rate">
161
- <FormattedNumber value={-courseProductRelation.discount_rate} style="percent" />
154
+ <FormattedNumber value={-offering.rules.discount_rate} style="percent" />
162
155
  </span>
163
156
  ) : (
164
157
  <span className="product-widget__header-discount-amount">
165
158
  <FormattedNumber
166
159
  currency={product.price_currency}
167
- value={-courseProductRelation.discount_amount!}
160
+ value={-offering.rules.discount_amount!}
168
161
  style="currency"
169
162
  />
170
163
  </span>
171
164
  )}
172
- {courseProductRelation.discount_start && (
165
+ {offering.rules.discount_start && (
173
166
  <span className="product-widget__header-discount-date">
174
167
  &nbsp;
175
168
  <FormattedMessage
176
169
  {...messages.from}
177
- values={{ from: formatDate(courseProductRelation.discount_start) }}
170
+ values={{ from: formatDate(offering.rules.discount_start) }}
178
171
  />
179
172
  </span>
180
173
  )}
181
- {courseProductRelation.discount_end && (
174
+ {offering.rules.discount_end && (
182
175
  <span className="product-widget__header-discount-date">
183
176
  &nbsp;
184
177
  <FormattedMessage
185
178
  {...messages.to}
186
- values={{ to: formatDate(courseProductRelation.discount_end) }}
179
+ values={{ to: formatDate(offering.rules.discount_end) }}
187
180
  />
188
181
  </span>
189
182
  )}
@@ -246,12 +239,18 @@ const Content = ({ product, order }: { product: Product; order?: CredentialOrder
246
239
  const CourseProductItem = ({ productId, course, compact = false }: CourseProductItemProps) => {
247
240
  // FIXME(rlecellier): useCourseProduct need's a filter on product.type that only return
248
241
  // CredentialOrder
249
- const { item: courseProductRelation, states: productQueryStates } = useCourseProduct({
250
- product_id: productId,
251
- course_id: course.code,
252
- });
242
+ const { item: offering, states: productQueryStates } = useCourseProduct(
243
+ {
244
+ product_id: productId,
245
+ course_id: course.code,
246
+ },
247
+ {
248
+ refetchOnMount: 'always',
249
+ refetchOnWindowFocus: 'always',
250
+ },
251
+ );
253
252
 
254
- const product = courseProductRelation?.product;
253
+ const product = offering?.product;
255
254
  const { item: productOrder, states: orderQueryStates } = useProductOrder({
256
255
  productId,
257
256
  courseCode: course.code,
@@ -309,7 +308,7 @@ const CourseProductItem = ({ productId, course, compact = false }: CourseProduct
309
308
  <Header
310
309
  product={product}
311
310
  order={order}
312
- courseProductRelation={courseProductRelation}
311
+ offering={offering}
313
312
  canPurchase={canPurchase}
314
313
  hasPurchased={hasPurchased}
315
314
  compact={compact}
@@ -318,7 +317,7 @@ const CourseProductItem = ({ productId, course, compact = false }: CourseProduct
318
317
  <footer className="product-widget__footer">
319
318
  <CourseProductItemFooter
320
319
  course={course}
321
- courseProductRelation={courseProductRelation}
320
+ offering={offering}
322
321
  canPurchase={canPurchase}
323
322
  />
324
323
  </footer>
@@ -0,0 +1,81 @@
1
+ import { Meta, StoryObj } from '@storybook/react';
2
+ import { CourseRunFactory, PacedCourseFactory } from 'utils/test/factories/richie';
3
+ import { StorybookHelper } from 'utils/StorybookHelper';
4
+ import { CourseCertificateOffer, CourseOffer } from '../../../../types/Course';
5
+ import { SyllabusCourseRun } from '.';
6
+
7
+ export default {
8
+ component: SyllabusCourseRun,
9
+ render: (args) => {
10
+ return StorybookHelper.wrapInApp(<SyllabusCourseRun {...args} />);
11
+ },
12
+ } as Meta<typeof SyllabusCourseRun>;
13
+
14
+ type Story = StoryObj<typeof SyllabusCourseRun>;
15
+
16
+ const courseRun = CourseRunFactory().one();
17
+
18
+ export const certificateSyllabusCourseRun: Story = {
19
+ args: {
20
+ courseRun: {
21
+ ...courseRun,
22
+ title: 'Certificate Product',
23
+ price_currency: 'EUR',
24
+ offer: CourseOffer.FREE,
25
+ certificate_offer: CourseCertificateOffer.PAID,
26
+ certificate_price: 100,
27
+ discounted_price: null,
28
+ discount: null,
29
+ },
30
+ course: PacedCourseFactory().one(),
31
+ showLanguages: true,
32
+ },
33
+ };
34
+ export const certificateDiscountSyllabusCourseRun: Story = {
35
+ args: {
36
+ courseRun: {
37
+ ...courseRun,
38
+ title: 'Certificate Product',
39
+ price_currency: 'EUR',
40
+ offer: CourseOffer.FREE,
41
+ certificate_offer: CourseCertificateOffer.PAID,
42
+ certificate_price: 100,
43
+ certificate_discounted_price: 80,
44
+ certificate_discount: '-20 €',
45
+ },
46
+ course: PacedCourseFactory().one(),
47
+ showLanguages: true,
48
+ },
49
+ };
50
+ export const credentialSyllabusCourseRun: Story = {
51
+ args: {
52
+ courseRun: {
53
+ ...courseRun,
54
+ title: 'Certificate Product',
55
+ price_currency: 'EUR',
56
+ offer: CourseOffer.PAID,
57
+ price: 100,
58
+ certificate_offer: CourseCertificateOffer.FREE,
59
+ discounted_price: null,
60
+ discount: null,
61
+ },
62
+ course: PacedCourseFactory().one(),
63
+ showLanguages: true,
64
+ },
65
+ };
66
+ export const credentialDiscountSyllabusCourseRun: Story = {
67
+ args: {
68
+ courseRun: {
69
+ ...courseRun,
70
+ title: 'Certificate Product',
71
+ price_currency: 'EUR',
72
+ offer: CourseOffer.PAID,
73
+ price: 100,
74
+ certificate_offer: CourseCertificateOffer.FREE,
75
+ discounted_price: 80,
76
+ discount: '-20 €',
77
+ },
78
+ course: PacedCourseFactory().one(),
79
+ showLanguages: true,
80
+ },
81
+ };
@@ -111,7 +111,9 @@ const OpenedCourseRun = ({
111
111
  let courseOfferMessage = null;
112
112
  let certificationOfferMessage = null;
113
113
  let enrollmentPrice = '';
114
+ let enrollmentDiscountedPrice = '';
114
115
  let certificatePrice = '';
116
+ let certificateDiscountedPrice = '';
115
117
 
116
118
  if (courseRun.offer) {
117
119
  const offer = courseRun.offer.toUpperCase().replaceAll(' ', '_');
@@ -128,6 +130,13 @@ const OpenedCourseRun = ({
128
130
  currency: courseRun.price_currency,
129
131
  });
130
132
  }
133
+
134
+ if ((courseRun.discounted_price ?? -1) >= 0) {
135
+ enrollmentDiscountedPrice = intl.formatNumber(courseRun.discounted_price!, {
136
+ style: 'currency',
137
+ currency: courseRun.price_currency,
138
+ });
139
+ }
131
140
  }
132
141
 
133
142
  if (courseRun.certificate_offer) {
@@ -144,6 +153,13 @@ const OpenedCourseRun = ({
144
153
  currency: courseRun.price_currency,
145
154
  });
146
155
  }
156
+
157
+ if ((courseRun.certificate_discounted_price ?? -1) >= 0) {
158
+ certificateDiscountedPrice = intl.formatNumber(courseRun.certificate_discounted_price!, {
159
+ style: 'currency',
160
+ currency: courseRun.price_currency,
161
+ });
162
+ }
147
163
  }
148
164
 
149
165
  return (
@@ -190,7 +206,16 @@ const OpenedCourseRun = ({
190
206
  <dd>
191
207
  <FormattedMessage {...courseOfferMessage} />
192
208
  <br />
193
- {enrollmentPrice}
209
+ {enrollmentDiscountedPrice ? (
210
+ <>
211
+ <del>{enrollmentPrice}</del>
212
+ <span>&nbsp;({courseRun.discount})</span>
213
+ <br />
214
+ <strong>{enrollmentDiscountedPrice}</strong>
215
+ </>
216
+ ) : (
217
+ enrollmentPrice
218
+ )}
194
219
  </dd>
195
220
  </>
196
221
  )}
@@ -202,7 +227,16 @@ const OpenedCourseRun = ({
202
227
  <dd>
203
228
  <FormattedMessage {...certificationOfferMessage} />
204
229
  <br />
205
- {certificatePrice}
230
+ {certificateDiscountedPrice ? (
231
+ <>
232
+ <del>{certificatePrice}</del>
233
+ <span>&nbsp;({courseRun.certificate_discount})</span>
234
+ <br />
235
+ <strong>{certificateDiscountedPrice}</strong>
236
+ </>
237
+ ) : (
238
+ certificatePrice
239
+ )}
206
240
  </dd>
207
241
  </>
208
242
  )}
@@ -102,7 +102,9 @@ const OpenedSelfPacedCourseRun = ({
102
102
  let courseOfferMessage = null;
103
103
  let certificationOfferMessage = null;
104
104
  let enrollmentPrice = '';
105
+ let enrollmentDiscountedPrice = '';
105
106
  let certificatePrice = '';
107
+ let certificateDiscountedPrice = '';
106
108
 
107
109
  if (courseRun.offer) {
108
110
  const offer = courseRun.offer.toUpperCase().replaceAll(' ', '_');
@@ -119,6 +121,13 @@ const OpenedSelfPacedCourseRun = ({
119
121
  currency: courseRun.price_currency,
120
122
  });
121
123
  }
124
+
125
+ if ((courseRun.discounted_price ?? -1) >= 0) {
126
+ enrollmentDiscountedPrice = intl.formatNumber(courseRun.discounted_price!, {
127
+ style: 'currency',
128
+ currency: courseRun.price_currency,
129
+ });
130
+ }
122
131
  }
123
132
 
124
133
  if (courseRun.certificate_offer) {
@@ -135,6 +144,13 @@ const OpenedSelfPacedCourseRun = ({
135
144
  currency: courseRun.price_currency,
136
145
  });
137
146
  }
147
+
148
+ if ((courseRun.certificate_discounted_price ?? -1) >= 0) {
149
+ certificateDiscountedPrice = intl.formatNumber(courseRun.certificate_discounted_price!, {
150
+ style: 'currency',
151
+ currency: courseRun.price_currency,
152
+ });
153
+ }
138
154
  }
139
155
 
140
156
  return (
@@ -174,7 +190,16 @@ const OpenedSelfPacedCourseRun = ({
174
190
  <dd>
175
191
  <FormattedMessage {...courseOfferMessage} />
176
192
  <br />
177
- {enrollmentPrice}
193
+ {enrollmentDiscountedPrice ? (
194
+ <>
195
+ <del>{enrollmentPrice}</del>
196
+ <span>&nbsp;({courseRun.discount})</span>
197
+ <br />
198
+ <strong>{enrollmentDiscountedPrice}</strong>
199
+ </>
200
+ ) : (
201
+ enrollmentPrice
202
+ )}
178
203
  </dd>
179
204
  </>
180
205
  )}
@@ -186,7 +211,16 @@ const OpenedSelfPacedCourseRun = ({
186
211
  <dd>
187
212
  <FormattedMessage {...certificationOfferMessage} />
188
213
  <br />
189
- {certificatePrice}
214
+ {certificateDiscountedPrice ? (
215
+ <>
216
+ <del>{certificatePrice}</del>
217
+ <span>&nbsp;({courseRun.certificate_discount})</span>
218
+ <br />
219
+ <strong>{certificateDiscountedPrice}</strong>
220
+ </>
221
+ ) : (
222
+ certificatePrice
223
+ )}
190
224
  </dd>
191
225
  </>
192
226
  )}
@@ -22,8 +22,8 @@ import {
22
22
  import SyllabusCourseRunsList from 'widgets/SyllabusCourseRunsList/index';
23
23
  import { createTestQueryClient } from 'utils/test/createTestQueryClient';
24
24
  import { CourseRun, Priority } from 'types';
25
- import { CourseProductRelation } from 'types/Joanie';
26
- import { CourseProductRelationFactory } from 'utils/test/factories/joanie';
25
+ import { Offering } from 'types/Joanie';
26
+ import { OfferingFactory } from 'utils/test/factories/joanie';
27
27
  import { DEFAULT_DATE_FORMAT } from 'hooks/useDateFormat';
28
28
  import { StringHelper } from 'utils/StringHelper';
29
29
  import { computeStates } from 'utils/CourseRuns';
@@ -211,9 +211,9 @@ describe('<SyllabusCourseRunsList/>', () => {
211
211
  });
212
212
  };
213
213
 
214
- const expectCourseProduct = async (container: HTMLElement, relation: CourseProductRelation) => {
214
+ const expectCourseProduct = async (container: HTMLElement, offering: Offering) => {
215
215
  const heading = await findByRole(container, 'heading', {
216
- name: relation.product.title,
216
+ name: offering.product.title,
217
217
  });
218
218
  expect(Array.from(heading.classList)).toContain('product-widget__title');
219
219
  };
@@ -383,9 +383,9 @@ describe('<SyllabusCourseRunsList/>', () => {
383
383
 
384
384
  it('has one opened product', async () => {
385
385
  const course = PacedCourseFactory().one();
386
- const relation = CourseProductRelationFactory().one();
387
- const resourceLink = `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${relation.product.id}/`;
388
- fetchMock.get(resourceLink, relation);
386
+ const offering = OfferingFactory().one();
387
+ const resourceLink = `https://joanie.endpoint/api/v1.0/courses/${course.code}/products/${offering.product.id}/`;
388
+ fetchMock.get(resourceLink, offering);
389
389
 
390
390
  const courseRun = CourseRunFactoryFromPriority(Priority.ONGOING_OPEN)({
391
391
  resource_link: resourceLink,
@@ -406,7 +406,7 @@ describe('<SyllabusCourseRunsList/>', () => {
406
406
  expect(getHeaderContainer().querySelectorAll('.course-detail__run-descriptions').length).toBe(
407
407
  1,
408
408
  );
409
- await expectCourseProduct(getHeaderContainer(), relation);
409
+ await expectCourseProduct(getHeaderContainer(), offering);
410
410
 
411
411
  // Portal.
412
412
  expectEmptyPortalContainer();
@@ -1465,4 +1465,54 @@ describe('<SyllabusCourseRunsList/>', () => {
1465
1465
  expect(content).not.toContain('The certification process is');
1466
1466
  expect(content).not.toContain('<br>€59.99');
1467
1467
  });
1468
+
1469
+ it('renders price discount on SyllabusCourseRun', async () => {
1470
+ const course = PacedCourseFactory().one();
1471
+ const courseRun: CourseRun = CourseRunFactoryFromPriority(Priority.ONGOING_OPEN)({
1472
+ languages: ['en'],
1473
+ price_currency: 'EUR',
1474
+ offer: 'paid',
1475
+ price: 49.99,
1476
+ certificate_offer: undefined,
1477
+ certificate_price: undefined,
1478
+ discounted_price: 30.0,
1479
+ discount: '-20%',
1480
+ }).one();
1481
+
1482
+ render(
1483
+ <div className="course-detail__row course-detail__runs course-detail__runs--open">
1484
+ <SyllabusCourseRunCompacted courseRun={courseRun} course={course} showLanguages={false} />
1485
+ </div>,
1486
+ );
1487
+
1488
+ const content = getHeaderContainer().innerHTML;
1489
+ expect(content).toContain(
1490
+ '<dd>Paid access<br><del>€49.99</del><span>&nbsp;(-20%)</span><br><strong>€30.00</strong></dd>',
1491
+ );
1492
+ });
1493
+
1494
+ it('renders certificate discount on SyllabusCourseRun', async () => {
1495
+ const course = PacedCourseFactory().one();
1496
+ const courseRun: CourseRun = CourseRunFactoryFromPriority(Priority.ONGOING_OPEN)({
1497
+ languages: ['en'],
1498
+ price_currency: 'EUR',
1499
+ offer: 'free',
1500
+ price: undefined,
1501
+ certificate_offer: 'paid',
1502
+ certificate_price: 100.0,
1503
+ certificate_discounted_price: 70.0,
1504
+ certificate_discount: '-30%',
1505
+ }).one();
1506
+
1507
+ render(
1508
+ <div className="course-detail__row course-detail__runs course-detail__runs--open">
1509
+ <SyllabusCourseRunCompacted courseRun={courseRun} course={course} showLanguages={false} />
1510
+ </div>,
1511
+ );
1512
+
1513
+ const content = getHeaderContainer().innerHTML;
1514
+ expect(content).toContain(
1515
+ '<dd>Paid certificate<br><del>€100.00</del><span>&nbsp;(-30%)</span><br><strong>€70.00</strong></dd>',
1516
+ );
1517
+ });
1468
1518
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "richie-education",
3
- "version": "3.1.3-dev8",
3
+ "version": "3.2.1-dev1",
4
4
  "description": "A CMS to build learning portals for Open Education",
5
5
  "main": "sandbox/manage.py",
6
6
  "scripts": {
@@ -90,6 +90,7 @@
90
90
  "cljs-merge": "1.1.1",
91
91
  "core-js": "3.41.0",
92
92
  "downshift": "9.0.9",
93
+ "embla-carousel-autoplay": "8.6.0",
93
94
  "embla-carousel-react": "8.5.2",
94
95
  "embla-carousel-wheel-gestures": "8.0.1",
95
96
  "eslint": ">=8.57.0 <9",
@@ -166,6 +166,9 @@ $r-theme: (
166
166
  index-color: r-color('battleship-grey'),
167
167
  index-hover-color: r-color('indianred3'),
168
168
  index-active-color: r-color('firebrick6'),
169
+ autoplay-color: r-color('white'),
170
+ autoplay-background-color: r-color('battleship-grey'),
171
+ autoplay-background-hover-color: r-color('charcoal'),
169
172
  ),
170
173
  blogpost-glimpse: (
171
174
  card-background: r-color('white'),
@@ -155,6 +155,25 @@ $r-slider-content-line-clamp: 4 !default;
155
155
  }
156
156
  }
157
157
 
158
+ .slider__autoplay {
159
+ display: flex;
160
+ justify-content: flex-end;
161
+ font-weight: bold;
162
+ margin-top: 0.5rem;
163
+ button {
164
+ cursor: pointer;
165
+ border-radius: 50px;
166
+ padding: 0.25rem 0.5rem;
167
+ border: none;
168
+ color: r-theme-val(slider-plugin, autoplay-color);
169
+ background-color: r-theme-val(slider-plugin, autoplay-background-color);
170
+ &:hover,
171
+ &:focus {
172
+ background-color: r-theme-val(slider-plugin, autoplay-background-hover-color);
173
+ }
174
+ }
175
+ }
176
+
158
177
  .slide__content {
159
178
  max-width: 680px;
160
179
 
@@ -55,6 +55,11 @@ $glimpse-gutter: 0.6rem;
55
55
  align-self: flex-end;
56
56
  }
57
57
  }
58
+ .section__grid--33x33x33 > &:nth-child(0n + 2) {
59
+ @include media-breakpoint-up(lg) {
60
+ align-self: unset;
61
+ }
62
+ }
58
63
 
59
64
  // Apply card styles for elements
60
65
  @include m-o-card(
@@ -396,6 +396,12 @@ $course-glimpse-content-padding-sides: 0.7rem !default;
396
396
  }
397
397
  }
398
398
 
399
+ .offer_prices {
400
+ display: flex;
401
+ flex-direction: column;
402
+ align-items: flex-end;
403
+ }
404
+
399
405
  .offer__price {
400
406
  $visibility: r-theme-val(course-glimpse, offer-price-visibility);
401
407
  @if $visibility == hidden {
@@ -404,6 +410,16 @@ $course-glimpse-content-padding-sides: 0.7rem !default;
404
410
  visibility: $visibility;
405
411
  // Align vertically the price with the icon
406
412
  margin-top: calc(1ex - 1cap);
413
+
414
+ &--striked,
415
+ &--discounted {
416
+ display: inline-block;
417
+ }
418
+
419
+ &--striked {
420
+ text-decoration: line-through;
421
+ opacity: 0.5;
422
+ }
407
423
  }
408
424
  }
409
425
  }
@@ -1,44 +0,0 @@
1
- import { defineMessages } from 'react-intl';
2
- import { useJoanieApi } from 'contexts/JoanieApiContext';
3
- import { API, CourseProductRelation, CourseProductRelationQueryFilters } from 'types/Joanie';
4
- import { useResource, useResources, UseResourcesProps } from 'hooks/useResources';
5
-
6
- const messages = defineMessages({
7
- errorGet: {
8
- id: 'hooks.useCourseProductRelations.errorGet',
9
- description:
10
- 'Error message shown to the user when course product relation fetch request fails.',
11
- defaultMessage: 'An error occurred while fetching trainings. Please retry later.',
12
- },
13
- errorNotFound: {
14
- id: 'hooks.useCourseProductRelations.errorNotFound',
15
- description: 'Error message shown to the user when no course product relation matches.',
16
- defaultMessage: 'Cannot find the training.',
17
- },
18
- });
19
-
20
- /**
21
- * Joanie Api hook to retrieve/create/update/delete course
22
- * owned by the authenticated user.
23
- */
24
- const props: UseResourcesProps<
25
- CourseProductRelation,
26
- CourseProductRelationQueryFilters,
27
- API['courseProductRelations']
28
- > = {
29
- queryKey: ['courseProductRelations'],
30
- apiInterface: () => useJoanieApi().courseProductRelations,
31
- session: true,
32
- messages,
33
- };
34
-
35
- export const useCourseProductRelations = useResources<
36
- CourseProductRelation,
37
- CourseProductRelationQueryFilters,
38
- API['courseProductRelations']
39
- >(props);
40
-
41
- export const useCourseProductRelation = useResource<
42
- CourseProductRelation,
43
- CourseProductRelationQueryFilters
44
- >(props);