richie-education 2.25.0-b2.dev81 → 2.25.0-b2.dev83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/components/RegisteredAddress/index.tsx +1 -1
- package/js/components/SaleTunnel/components/SaleTunnelStepPayment/index.spec.tsx +4 -0
- package/js/components/SaleTunnel/components/SaleTunnelStepPayment/index.tsx +2 -1
- package/js/components/TeacherDashboardCourseList/index.spec.tsx +4 -4
- package/js/components/TeacherDashboardCourseList/index.tsx +2 -1
- package/js/hooks/useCourseProductUnion/index.ts +4 -1
- package/js/pages/TeacherDashboardCoursesLoader/index.spec.tsx +2 -2
- package/js/types/Joanie.ts +1 -0
- package/package.json +1 -1
|
@@ -61,7 +61,7 @@ const RegisteredAddress = ({ promote, select, edit, remove, address }: Props) =>
|
|
|
61
61
|
<Radio
|
|
62
62
|
aria-describedby={`address-${address.id}-infos`}
|
|
63
63
|
aria-label={intl.formatMessage(messages.promoteButtonLabel, { title: address.title })}
|
|
64
|
-
|
|
64
|
+
onChange={() => promote(address)}
|
|
65
65
|
title={intl.formatMessage(messages.promoteButtonLabel, { title: address.title })}
|
|
66
66
|
name="registered-addresses"
|
|
67
67
|
checked={address.is_main}
|
|
@@ -5,6 +5,7 @@ import { QueryClientProvider } from '@tanstack/react-query';
|
|
|
5
5
|
import { CunninghamProvider } from '@openfun/cunningham-react';
|
|
6
6
|
import { PropsWithChildren, useMemo, useState } from 'react';
|
|
7
7
|
import userEvent from '@testing-library/user-event';
|
|
8
|
+
import { queryByRole } from '@testing-library/dom';
|
|
8
9
|
import {
|
|
9
10
|
RichieContextFactory as mockRichieContextFactory,
|
|
10
11
|
UserFactory,
|
|
@@ -210,6 +211,9 @@ describe('SaleTunnelStepPayment', () => {
|
|
|
210
211
|
},
|
|
211
212
|
);
|
|
212
213
|
|
|
214
|
+
// The select field should not be clearable
|
|
215
|
+
expect(queryByRole(dropdown, 'button', { name: 'Clear selection' })).toBeNull();
|
|
216
|
+
|
|
213
217
|
// A button to add an address should be displayed
|
|
214
218
|
const $button = screen.getByText('Add an address', { selector: 'button' });
|
|
215
219
|
|
|
@@ -123,7 +123,7 @@ export const SaleTunnelStepPayment = ({ next }: SaleTunnelStepPaymentProps) => {
|
|
|
123
123
|
* Retrieve address through its `id` provided by the event target value
|
|
124
124
|
* then update `selectedAddress` state
|
|
125
125
|
*
|
|
126
|
-
* @param {
|
|
126
|
+
* @param {string} newValue
|
|
127
127
|
*/
|
|
128
128
|
const handleSelectAddress = (newValue: string) => {
|
|
129
129
|
const targetedAddress = addresses.items.find((a) => a.id === newValue);
|
|
@@ -220,6 +220,7 @@ export const SaleTunnelStepPayment = ({ next }: SaleTunnelStepPaymentProps) => {
|
|
|
220
220
|
<Select
|
|
221
221
|
className="form-field--minimal"
|
|
222
222
|
name="invoice_address"
|
|
223
|
+
clearable={false}
|
|
223
224
|
label={intl.formatMessage(messages.userBillingAddressSelectLabel)}
|
|
224
225
|
onChange={(e) => handleSelectAddress((e.target.value || '') as string)}
|
|
225
226
|
defaultValue={selectedAddress!.id || ''}
|
|
@@ -68,7 +68,7 @@ describe('components/TeacherDashboardCourseList', () => {
|
|
|
68
68
|
title: "Full training: Let's dance, the online lesson",
|
|
69
69
|
}).one();
|
|
70
70
|
fetchMock.get(
|
|
71
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
71
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
72
72
|
mockPaginatedResponse([productCooking, productDancing], 15, false),
|
|
73
73
|
);
|
|
74
74
|
|
|
@@ -98,7 +98,7 @@ describe('components/TeacherDashboardCourseList', () => {
|
|
|
98
98
|
`https://joanie.endpoint/api/v1.0/courses/?has_listed_course_runs=true&page=1&page_size=${perPage}`,
|
|
99
99
|
);
|
|
100
100
|
expect(calledUrls).toContain(
|
|
101
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
101
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
102
102
|
);
|
|
103
103
|
|
|
104
104
|
expect(
|
|
@@ -124,7 +124,7 @@ describe('components/TeacherDashboardCourseList', () => {
|
|
|
124
124
|
},
|
|
125
125
|
);
|
|
126
126
|
fetchMock.get(
|
|
127
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
127
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
128
128
|
mockPaginatedResponse([], 0, false),
|
|
129
129
|
{
|
|
130
130
|
overwriteRoutes: true,
|
|
@@ -154,7 +154,7 @@ describe('components/TeacherDashboardCourseList', () => {
|
|
|
154
154
|
`https://joanie.endpoint/api/v1.0/courses/?has_listed_course_runs=true&page=1&page_size=${perPage}`,
|
|
155
155
|
);
|
|
156
156
|
expect(calledUrls).toContain(
|
|
157
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
157
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
158
158
|
);
|
|
159
159
|
|
|
160
160
|
expect(await screen.findByText('You have no courses yet.')).toBeInTheDocument();
|
|
@@ -6,6 +6,7 @@ import { Spinner } from 'components/Spinner';
|
|
|
6
6
|
import context from 'utils/context';
|
|
7
7
|
import { useCourseProductUnion } from 'hooks/useCourseProductUnion';
|
|
8
8
|
import { useIntersectionObserver } from 'hooks/useIntersectionObserver';
|
|
9
|
+
import { ProductType } from 'types/Joanie';
|
|
9
10
|
|
|
10
11
|
const messages = defineMessages({
|
|
11
12
|
loading: {
|
|
@@ -41,7 +42,7 @@ const TeacherDashboardCourseList = ({
|
|
|
41
42
|
isLoading,
|
|
42
43
|
next,
|
|
43
44
|
hasMore,
|
|
44
|
-
} = useCourseProductUnion({ perPage: 25, organizationId });
|
|
45
|
+
} = useCourseProductUnion({ perPage: 25, organizationId, productType: ProductType.CREDENTIAL });
|
|
45
46
|
useIntersectionObserver({
|
|
46
47
|
target: loadMoreButtonRef,
|
|
47
48
|
onIntersect: next,
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
CourseProductRelation,
|
|
7
7
|
CourseQueryFilters,
|
|
8
8
|
CourseProductRelationQueryFilters,
|
|
9
|
+
ProductType,
|
|
9
10
|
} from 'types/Joanie';
|
|
10
11
|
import useUnionResource, { ResourceUnionPaginationProps } from 'hooks/useUnionResource';
|
|
11
12
|
|
|
@@ -26,11 +27,13 @@ const messages = defineMessages({
|
|
|
26
27
|
|
|
27
28
|
interface UseCourseProductUnionProps extends ResourceUnionPaginationProps {
|
|
28
29
|
organizationId?: string;
|
|
30
|
+
productType?: ProductType;
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
export const useCourseProductUnion = ({
|
|
32
34
|
perPage = 50,
|
|
33
35
|
organizationId,
|
|
36
|
+
productType,
|
|
34
37
|
}: UseCourseProductUnionProps = {}) => {
|
|
35
38
|
const api = useJoanieApi();
|
|
36
39
|
return useUnionResource<
|
|
@@ -47,7 +50,7 @@ export const useCourseProductUnion = ({
|
|
|
47
50
|
queryBConfig: {
|
|
48
51
|
queryKey: ['user', 'course_product_relations'],
|
|
49
52
|
fn: api.courseProductRelations.get,
|
|
50
|
-
filters: { organization_id: organizationId },
|
|
53
|
+
filters: { organization_id: organizationId, product_type: productType },
|
|
51
54
|
},
|
|
52
55
|
perPage,
|
|
53
56
|
errorGetMessage: messages.errorGet,
|
|
@@ -57,7 +57,7 @@ describe('components/TeacherDashboardCoursesLoader', () => {
|
|
|
57
57
|
mockPaginatedResponse(CourseListItemFactory().many(15), 15, false),
|
|
58
58
|
);
|
|
59
59
|
fetchMock.get(
|
|
60
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
60
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
61
61
|
mockPaginatedResponse(CourseProductRelationFactory().many(15), 15, false),
|
|
62
62
|
);
|
|
63
63
|
|
|
@@ -87,7 +87,7 @@ describe('components/TeacherDashboardCoursesLoader', () => {
|
|
|
87
87
|
const calledUrls = fetchMock.calls().map((call) => call[0]);
|
|
88
88
|
expect(calledUrls).toHaveLength(nbApiCalls);
|
|
89
89
|
expect(calledUrls).toContain(
|
|
90
|
-
`https://joanie.endpoint/api/v1.0/course-product-relations/?page=1&page_size=${perPage}`,
|
|
90
|
+
`https://joanie.endpoint/api/v1.0/course-product-relations/?product_type=credential&page=1&page_size=${perPage}`,
|
|
91
91
|
);
|
|
92
92
|
|
|
93
93
|
// section titles
|
package/js/types/Joanie.ts
CHANGED
|
@@ -435,6 +435,7 @@ export interface CourseProductQueryFilters extends ResourcesQuery {
|
|
|
435
435
|
export interface CourseProductRelationQueryFilters extends PaginatedResourceQuery {
|
|
436
436
|
id?: CourseProductRelation['id'];
|
|
437
437
|
organization_id?: Organization['id'];
|
|
438
|
+
product_type?: ProductType;
|
|
438
439
|
}
|
|
439
440
|
|
|
440
441
|
export enum ContractState {
|