richie-education 2.25.0-b2.dev82 → 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/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
|
@@ -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 {
|