Skip to content

Commit 8726fc3

Browse files
chore: improving querykeys
1 parent 710c3a6 commit 8726fc3

File tree

6 files changed

+11
-9
lines changed

6 files changed

+11
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"*.scss"
1919
],
2020
"scripts": {
21-
"dev": "PORT=8081 PUBLIC_PATH=/instructor openedx dev",
21+
"dev": "PORT=8080 PUBLIC_PATH=/instructor openedx dev",
2222
"i18n_extract": "openedx formatjs extract",
2323
"lint": "openedx lint .",
2424
"lint:fix": "openedx lint --fix .",

src/dateExtensions/DateExtensionsPage.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import { render, screen } from '@testing-library/react';
22
import { IntlProvider } from '@openedx/frontend-base';
33
import { MemoryRouter, Route, Routes } from 'react-router-dom';
44
import DateExtensionsPage from './DateExtensionsPage';
5-
import { useDateExtensions } from '../data/apiHook';
5+
import { useDateExtensions } from './data/apiHook';
66

7-
jest.mock('../data/apiHook', () => ({
7+
jest.mock('./data/apiHook', () => ({
88
useDateExtensions: jest.fn(),
99
}));
1010

src/dateExtensions/components/DateExtensionsList.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { screen } from '@testing-library/react';
22
import userEvent from '@testing-library/user-event';
33
import DateExtensionsList, { DateExtensionListProps } from './DateExtensionsList';
44
import { renderWithIntl } from '../../testUtils';
5-
import { useDateExtensions } from '../../data/apiHook';
5+
import { useDateExtensions } from '../data/apiHook';
66

77
const mockData = [
88
{
@@ -15,7 +15,7 @@ const mockData = [
1515
}
1616
];
1717

18-
jest.mock('../../data/apiHook', () => ({
18+
jest.mock('../data/apiHook', () => ({
1919
useDateExtensions: jest.fn(),
2020
}));
2121

src/dateExtensions/components/DateExtensionsList.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useIntl } from '@openedx/frontend-base';
22
import { Button, DataTable } from '@openedx/paragon';
33
import messages from '../messages';
44
import { LearnerDateExtension } from '../types';
5-
import { useDateExtensions } from '../../data/apiHook';
5+
import { useDateExtensions } from '../data/apiHook';
66
import { useParams } from 'react-router-dom';
77
import { useState } from 'react';
88

@@ -12,7 +12,7 @@ import { useState } from 'react';
1212
// { id: 2, username: 'dianaSalas', fullname: 'Diana Villalvazo', email: 'diana.villalvazo@example.com', graded_subsection: 'Three body diagrams', extended_due_date: '2026-07-15' },
1313
// ];
1414

15-
export const DATE_EXTENSIONS_PAGE_SIZE = 25;
15+
const DATE_EXTENSIONS_PAGE_SIZE = 25;
1616

1717
export interface DateExtensionListProps {
1818
onResetExtensions?: (user: LearnerDateExtension) => void,

src/dateExtensions/data/apiHook.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { dateExtensionsQueryKeys } from './queryKeys';
44

55
export const useDateExtensions = (courseId: string, pagination: PaginationQueryKeys) => (
66
useQuery({
7-
queryKey: dateExtensionsQueryKeys.byCourse(courseId),
7+
queryKey: dateExtensionsQueryKeys.byCoursePaginated(courseId, pagination),
88
queryFn: () => getDateExtensions(courseId, pagination),
99
})
1010
);
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { appId } from '../../constants';
2+
import { PaginationQueryKeys } from './api';
23

34
export const dateExtensionsQueryKeys = {
45
all: [appId, 'dateExtensions'] as const,
5-
byCourse: (courseId: string) => [appId, 'dateExtensions', courseId] as const,
6+
byCourse: (courseId: string) => [...dateExtensionsQueryKeys.all, courseId] as const,
7+
byCoursePaginated: (courseId: string, pagination: PaginationQueryKeys) => [...dateExtensionsQueryKeys.byCourse(courseId), pagination.page] as const,
68
};

0 commit comments

Comments
 (0)