codeforlife 2.8.2 → 2.9.0
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/dist/Countdown-DFI1RljW.js +28 -0
- package/dist/Countdown-DFI1RljW.js.map +1 -0
- package/dist/Countdown-zY3nMzmi.cjs +2 -0
- package/dist/Countdown-zY3nMzmi.cjs.map +1 -0
- package/dist/Image-D5jC9UoX.js +21 -0
- package/dist/Image-D5jC9UoX.js.map +1 -0
- package/dist/Image-mgT45r_B.cjs +2 -0
- package/dist/Image-mgT45r_B.cjs.map +1 -0
- package/dist/LinkButton-BYFkvL_O.cjs +2 -0
- package/dist/LinkButton-BYFkvL_O.cjs.map +1 -0
- package/dist/LinkButton-oK0RThqn.js +12 -0
- package/dist/LinkButton-oK0RThqn.js.map +1 -0
- package/dist/Navigate-Dq47aqC8.js +25 -0
- package/dist/Navigate-Dq47aqC8.js.map +1 -0
- package/dist/Navigate-dQocLhzN.cjs +2 -0
- package/dist/Navigate-dQocLhzN.cjs.map +1 -0
- package/dist/api/endpoints/index.cjs.js +2 -0
- package/dist/api/endpoints/index.cjs.js.map +1 -0
- package/dist/api/endpoints/index.d.ts +81 -0
- package/dist/api/endpoints/index.es.js +78 -0
- package/dist/api/endpoints/index.es.js.map +1 -0
- package/dist/api/index.cjs.js +4 -0
- package/dist/api/index.cjs.js.map +1 -0
- package/dist/api/index.d.ts +77 -0
- package/dist/api/index.es.js +541 -0
- package/dist/api/index.es.js.map +1 -0
- package/dist/api-Cbyt3rw0.js +92 -0
- package/dist/api-Cbyt3rw0.js.map +1 -0
- package/dist/api-CnMfjRk3.cjs +2 -0
- package/dist/api-CnMfjRk3.cjs.map +1 -0
- package/dist/api-Cs4Y-WeI.js +20 -0
- package/dist/api-Cs4Y-WeI.js.map +1 -0
- package/dist/api-DIgp_6Vr.cjs +2 -0
- package/dist/api-DIgp_6Vr.cjs.map +1 -0
- package/dist/api.d.ts +123 -0
- package/dist/auth-BPfUPjmM.js +237 -0
- package/dist/auth-BPfUPjmM.js.map +1 -0
- package/dist/auth-Vf1MgMci.cjs +2 -0
- package/dist/auth-Vf1MgMci.cjs.map +1 -0
- package/dist/auth.d.ts +40 -0
- package/dist/components/form/index.cjs.js +2 -0
- package/dist/components/form/index.cjs.js.map +1 -0
- package/dist/components/form/index.d.ts +86 -0
- package/dist/components/form/index.es.js +18 -0
- package/dist/components/form/index.es.js.map +1 -0
- package/dist/components/index.cjs.js +11 -0
- package/dist/components/index.cjs.js.map +1 -0
- package/dist/components/index.d.ts +90 -0
- package/dist/components/index.es.js +383 -0
- package/dist/components/index.es.js.map +1 -0
- package/dist/components/page/index.cjs.js +2 -0
- package/dist/components/page/index.cjs.js.map +1 -0
- package/dist/components/page/index.d.ts +77 -0
- package/dist/components/page/index.es.js +9 -0
- package/dist/components/page/index.es.js.map +1 -0
- package/dist/components/router/index.cjs.js +2 -0
- package/dist/components/router/index.cjs.js.map +1 -0
- package/dist/components/router/index.d.ts +78 -0
- package/dist/components/router/index.es.js +11 -0
- package/dist/components/router/index.es.js.map +1 -0
- package/dist/components/table/index.cjs.js +2 -0
- package/dist/components/table/index.cjs.js.map +1 -0
- package/dist/components/table/index.d.ts +75 -0
- package/dist/components/table/index.es.js +9 -0
- package/dist/components/table/index.es.js.map +1 -0
- package/dist/en-gb-B_rK7Jx1.js +20 -0
- package/dist/en-gb-B_rK7Jx1.js.map +1 -0
- package/dist/en-gb-CpyEkKq3.cjs +2 -0
- package/dist/en-gb-CpyEkKq3.cjs.map +1 -0
- package/dist/features/index.cjs.js +2 -0
- package/dist/features/index.cjs.js.map +1 -0
- package/dist/features/index.d.ts +76 -0
- package/dist/features/index.es.js +47 -0
- package/dist/features/index.es.js.map +1 -0
- package/dist/form.d.ts +40 -0
- package/dist/general-BPbbmkeX.cjs +2 -0
- package/dist/general-BPbbmkeX.cjs.map +1 -0
- package/dist/general-CtTJPCJn.js +58 -0
- package/dist/general-CtTJPCJn.js.map +1 -0
- package/dist/general.d.ts +53 -0
- package/dist/hooks/index.cjs.js +2 -0
- package/dist/hooks/index.cjs.js.map +1 -0
- package/dist/hooks/index.d.ts +77 -0
- package/dist/hooks/index.es.js +25 -0
- package/dist/hooks/index.es.js.map +1 -0
- package/dist/index-2W--_sNE.js +30 -0
- package/dist/index-2W--_sNE.js.map +1 -0
- package/dist/index-BUMdUVBH.cjs +5 -0
- package/dist/index-BUMdUVBH.cjs.map +1 -0
- package/dist/index-B_Zy_zwA.cjs +2 -0
- package/dist/index-B_Zy_zwA.cjs.map +1 -0
- package/dist/index-BgsynEGX.cjs +2 -0
- package/dist/index-BgsynEGX.cjs.map +1 -0
- package/dist/index-CA-ugBSa.cjs +2 -0
- package/dist/index-CA-ugBSa.cjs.map +1 -0
- package/dist/index-CNtOlJ49.js +572 -0
- package/dist/index-CNtOlJ49.js.map +1 -0
- package/dist/index-DkM_cG3a.js +237 -0
- package/dist/index-DkM_cG3a.js.map +1 -0
- package/dist/index-Dqp7dpn3.js +1111 -0
- package/dist/index-Dqp7dpn3.js.map +1 -0
- package/dist/index.cjs.js +2 -0
- package/dist/index.cjs.js.map +1 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.es.js +7 -0
- package/dist/index.es.js.map +1 -0
- package/dist/jsx-runtime-CeSfJrVB.cjs +31 -0
- package/dist/jsx-runtime-CeSfJrVB.cjs.map +1 -0
- package/dist/jsx-runtime-Dpn_P65e.js +634 -0
- package/dist/jsx-runtime-Dpn_P65e.js.map +1 -0
- package/dist/middlewares/index.cjs.js +2 -0
- package/dist/middlewares/index.cjs.js.map +1 -0
- package/dist/middlewares/index.d.ts +73 -0
- package/dist/middlewares/index.es.js +10 -0
- package/dist/middlewares/index.es.js.map +1 -0
- package/dist/palette-CE2mKYse.cjs +2 -0
- package/dist/palette-CE2mKYse.cjs.map +1 -0
- package/dist/palette-C_L0akN_.js +43 -0
- package/dist/palette-C_L0akN_.js.map +1 -0
- package/dist/router.d.ts +48 -0
- package/dist/rtk-query.modern-CjetfYPg.js +3038 -0
- package/dist/rtk-query.modern-CjetfYPg.js.map +1 -0
- package/dist/rtk-query.modern-PBCErCqb.cjs +15 -0
- package/dist/rtk-query.modern-PBCErCqb.cjs.map +1 -0
- package/dist/schema.d.ts +89 -0
- package/dist/schemas-BZbJpkD5.cjs +2 -0
- package/dist/schemas-BZbJpkD5.cjs.map +1 -0
- package/dist/schemas-DlOtf2vf.js +162 -0
- package/dist/schemas-DlOtf2vf.js.map +1 -0
- package/dist/server.cjs.js +6 -0
- package/dist/server.cjs.js.map +1 -0
- package/dist/server.d.ts +129 -0
- package/dist/server.es.js +127 -0
- package/dist/server.es.js.map +1 -0
- package/dist/session-CE2U7oL1.cjs +2 -0
- package/dist/session-CE2U7oL1.cjs.map +1 -0
- package/dist/session-CacrgFSv.cjs +2 -0
- package/dist/session-CacrgFSv.cjs.map +1 -0
- package/dist/session-D312kYKk.js +32 -0
- package/dist/session-D312kYKk.js.map +1 -0
- package/dist/session-oI-Ht2C8.js +30 -0
- package/dist/session-oI-Ht2C8.js.map +1 -0
- package/dist/settings/index.cjs.js +2 -0
- package/dist/settings/index.cjs.js.map +1 -0
- package/dist/settings/index.d.ts +76 -0
- package/dist/settings/index.es.js +17 -0
- package/dist/settings/index.es.js.map +1 -0
- package/dist/slices/index.cjs.js +2 -0
- package/dist/slices/index.cjs.js.map +1 -0
- package/dist/slices/index.d.ts +74 -0
- package/dist/slices/index.es.js +6 -0
- package/dist/slices/index.es.js.map +1 -0
- package/dist/store.d.ts +17 -0
- package/dist/style.css +1 -0
- package/dist/test.d.ts +75 -0
- package/dist/theme/components/index.cjs.js +2 -0
- package/dist/theme/components/index.cjs.js.map +1 -0
- package/dist/theme/components/index.d.ts +75 -0
- package/dist/theme/components/index.es.js +6 -0
- package/dist/theme/components/index.es.js.map +1 -0
- package/dist/theme/index.cjs.js +2 -0
- package/dist/theme/index.cjs.js.map +1 -0
- package/dist/theme/index.d.ts +79 -0
- package/dist/theme/index.es.js +222 -0
- package/dist/theme/index.es.js.map +1 -0
- package/dist/theme.d.ts +19 -0
- package/dist/urls-DtHr1d3H.js +14 -0
- package/dist/urls-DtHr1d3H.js.map +1 -0
- package/dist/urls-MaVXL_C2.cjs +2 -0
- package/dist/urls-MaVXL_C2.cjs.map +1 -0
- package/dist/utils/api.cjs.js +2 -0
- package/dist/utils/api.cjs.js.map +1 -0
- package/dist/utils/api.d.ts +144 -0
- package/dist/utils/api.es.js +16 -0
- package/dist/utils/api.es.js.map +1 -0
- package/dist/utils/auth.cjs.js +2 -0
- package/dist/utils/auth.cjs.js.map +1 -0
- package/dist/utils/auth.d.ts +100 -0
- package/dist/utils/auth.es.js +117 -0
- package/dist/utils/auth.es.js.map +1 -0
- package/dist/utils/form.cjs.js +2 -0
- package/dist/utils/form.cjs.js.map +1 -0
- package/dist/utils/form.d.ts +97 -0
- package/dist/utils/form.es.js +76 -0
- package/dist/utils/form.es.js.map +1 -0
- package/dist/utils/general.cjs.js +2 -0
- package/dist/utils/general.cjs.js.map +1 -0
- package/dist/utils/general.d.ts +102 -0
- package/{src/utils/general.ts → dist/utils/general.es.js} +87 -165
- package/dist/utils/general.es.js.map +1 -0
- package/dist/utils/router.cjs.js +2 -0
- package/dist/utils/router.cjs.js.map +1 -0
- package/dist/utils/router.d.ts +91 -0
- package/dist/utils/router.es.js +33 -0
- package/dist/utils/router.es.js.map +1 -0
- package/dist/utils/schema.cjs.js +2 -0
- package/dist/utils/schema.cjs.js.map +1 -0
- package/dist/utils/schema.d.ts +115 -0
- package/dist/utils/schema.es.js +123 -0
- package/dist/utils/schema.es.js.map +1 -0
- package/dist/utils/store.cjs.js +2 -0
- package/dist/utils/store.cjs.js.map +1 -0
- package/dist/utils/store.d.ts +82 -0
- package/dist/utils/store.es.js +20 -0
- package/dist/utils/store.es.js.map +1 -0
- package/dist/utils/test.cjs.js +2 -0
- package/dist/utils/test.cjs.js.map +1 -0
- package/dist/utils/test.d.ts +125 -0
- package/dist/utils/test.es.js +60 -0
- package/dist/utils/test.es.js.map +1 -0
- package/dist/utils/theme.cjs.js +2 -0
- package/dist/utils/theme.cjs.js.map +1 -0
- package/dist/utils/theme.d.ts +83 -0
- package/dist/utils/theme.es.js +12 -0
- package/dist/utils/theme.es.js.map +1 -0
- package/dist/utils/window.cjs.js +2 -0
- package/dist/utils/window.cjs.js.map +1 -0
- package/dist/utils/window.d.ts +74 -0
- package/dist/utils/window.es.js +11 -0
- package/dist/utils/window.es.js.map +1 -0
- package/dist/window.d.ts +5 -0
- package/package.json +142 -37
- package/.github/workflows/main.yml +0 -55
- package/.prettierignore +0 -1
- package/CHANGELOG.md +0 -2020
- package/CONTRIBUTING.md +0 -3
- package/eslint.config.js +0 -17
- package/src/api/createApi.ts +0 -91
- package/src/api/endpoints/authFactor.ts +0 -31
- package/src/api/endpoints/index.ts +0 -9
- package/src/api/endpoints/klass.ts +0 -87
- package/src/api/endpoints/school.ts +0 -34
- package/src/api/endpoints/session.ts +0 -47
- package/src/api/endpoints/user.ts +0 -70
- package/src/api/index.ts +0 -5
- package/src/api/models.ts +0 -145
- package/src/api/schemas.ts +0 -243
- package/src/api/tagTypes.ts +0 -12
- package/src/api/urls.ts +0 -13
- package/src/components/App.css +0 -38
- package/src/components/App.tsx +0 -152
- package/src/components/ClickableTooltip.tsx +0 -43
- package/src/components/CopyIconButton.test.tsx +0 -16
- package/src/components/CopyIconButton.tsx +0 -27
- package/src/components/Countdown.tsx +0 -42
- package/src/components/DownloadFileButton.tsx +0 -55
- package/src/components/ElevatedAppBar.tsx +0 -41
- package/src/components/Image.tsx +0 -41
- package/src/components/InputFileButton.tsx +0 -27
- package/src/components/ItemizedList.tsx +0 -61
- package/src/components/OrderedGrid.tsx +0 -92
- package/src/components/ScrollIntoViewLink.tsx +0 -22
- package/src/components/SyncError.tsx +0 -14
- package/src/components/TablePagination.tsx +0 -142
- package/src/components/YouTubeVideo.tsx +0 -26
- package/src/components/form/ApiAutocompleteField.tsx +0 -187
- package/src/components/form/AutocompleteField.tsx +0 -135
- package/src/components/form/CheckboxField.tsx +0 -86
- package/src/components/form/CountryField.tsx +0 -75
- package/src/components/form/DatePickerField.tsx +0 -126
- package/src/components/form/EmailField.tsx +0 -38
- package/src/components/form/FirstNameField.tsx +0 -40
- package/src/components/form/Form.tsx +0 -165
- package/src/components/form/OtpField.tsx +0 -28
- package/src/components/form/PasswordField.tsx +0 -71
- package/src/components/form/RepeatField.tsx +0 -123
- package/src/components/form/SubmitButton.tsx +0 -57
- package/src/components/form/TextField.tsx +0 -150
- package/src/components/form/UkCountyField.tsx +0 -68
- package/src/components/form/index.tsx +0 -35
- package/src/components/index.ts +0 -28
- package/src/components/page/Banner.tsx +0 -95
- package/src/components/page/Notification.tsx +0 -71
- package/src/components/page/Page.tsx +0 -73
- package/src/components/page/Section.tsx +0 -21
- package/src/components/page/TabBar.tsx +0 -131
- package/src/components/page/index.ts +0 -10
- package/src/components/router/Link.tsx +0 -23
- package/src/components/router/LinkButton.tsx +0 -22
- package/src/components/router/LinkIconButton.tsx +0 -22
- package/src/components/router/LinkListItem.tsx +0 -22
- package/src/components/router/LinkTab.tsx +0 -22
- package/src/components/router/Navigate.tsx +0 -33
- package/src/components/router/index.tsx +0 -9
- package/src/components/table/CellStack.tsx +0 -19
- package/src/components/table/Table.tsx +0 -55
- package/src/components/table/index.tsx +0 -8
- package/src/features/InactiveDialog.tsx +0 -40
- package/src/features/ScreenTimeDialog.tsx +0 -30
- package/src/features/index.ts +0 -4
- package/src/fonts/ttf/Inter-VariableFont_slnt,wght.ttf +0 -0
- package/src/fonts/ttf/SpaceGrotesk-VariableFont_wght.ttf +0 -0
- package/src/hooks/api.tsx +0 -39
- package/src/hooks/auth.tsx +0 -397
- package/src/hooks/form.tsx +0 -11
- package/src/hooks/general.tsx +0 -110
- package/src/hooks/index.ts +0 -5
- package/src/hooks/router.tsx +0 -168
- package/src/images/svg/brain.svg +0 -1
- package/src/index.ts +0 -2
- package/src/middlewares/index.ts +0 -1
- package/src/middlewares/session.ts +0 -21
- package/src/scripts/freshDesk.js +0 -473
- package/src/scripts/index.ts +0 -1
- package/src/server.js +0 -187
- package/src/settings/custom.ts +0 -22
- package/src/settings/index.ts +0 -7
- package/src/settings/vite.ts +0 -26
- package/src/setupTests.ts +0 -2
- package/src/slices/createSlice.ts +0 -8
- package/src/slices/index.ts +0 -2
- package/src/slices/session.ts +0 -32
- package/src/theme/ThemedBox.tsx +0 -265
- package/src/theme/colors.ts +0 -57
- package/src/theme/components/MuiAccordion.tsx +0 -13
- package/src/theme/components/MuiAutocomplete.tsx +0 -11
- package/src/theme/components/MuiButton.ts +0 -70
- package/src/theme/components/MuiCardActions.tsx +0 -12
- package/src/theme/components/MuiCheckbox.ts +0 -12
- package/src/theme/components/MuiContainer.ts +0 -19
- package/src/theme/components/MuiDialog.tsx +0 -16
- package/src/theme/components/MuiFormControlLabel.ts +0 -18
- package/src/theme/components/MuiFormHelperText.ts +0 -12
- package/src/theme/components/MuiGrid2.ts +0 -16
- package/src/theme/components/MuiInputBase.ts +0 -14
- package/src/theme/components/MuiLink.ts +0 -41
- package/src/theme/components/MuiList.ts +0 -12
- package/src/theme/components/MuiListItemText.ts +0 -18
- package/src/theme/components/MuiMenu.ts +0 -14
- package/src/theme/components/MuiMenuItem.ts +0 -15
- package/src/theme/components/MuiSelect.ts +0 -16
- package/src/theme/components/MuiTab.ts +0 -29
- package/src/theme/components/MuiTable.ts +0 -29
- package/src/theme/components/MuiTableBody.ts +0 -15
- package/src/theme/components/MuiTableHead.ts +0 -26
- package/src/theme/components/MuiTabs.ts +0 -26
- package/src/theme/components/MuiTextField.ts +0 -86
- package/src/theme/components/MuiToolbar.ts +0 -11
- package/src/theme/components/MuiTypography.ts +0 -12
- package/src/theme/components/_components.ts +0 -95
- package/src/theme/components/index.ts +0 -57
- package/src/theme/index.ts +0 -25
- package/src/theme/palette.ts +0 -98
- package/src/theme/spacing.ts +0 -8
- package/src/theme/typography.ts +0 -101
- package/src/utils/api.test.ts +0 -19
- package/src/utils/api.tsx +0 -339
- package/src/utils/auth.ts +0 -78
- package/src/utils/form.test.ts +0 -50
- package/src/utils/form.ts +0 -193
- package/src/utils/general.test.ts +0 -55
- package/src/utils/router.test.ts +0 -156
- package/src/utils/router.ts +0 -67
- package/src/utils/schema.ts +0 -290
- package/src/utils/store.ts +0 -31
- package/src/utils/test.tsx +0 -82
- package/src/utils/theme.tsx +0 -83
- package/src/utils/window.ts +0 -11
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.app.json +0 -4
- package/tsconfig.json +0 -7
- package/tsconfig.node.json +0 -4
- package/types/fixes.d.ts +0 -18
- package/vite.config.ts +0 -23
package/CONTRIBUTING.md
DELETED
package/eslint.config.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import workspaceConfig from "@codeforlife/workspace/eslint.config.js"
|
|
2
|
-
import ts from "typescript-eslint"
|
|
3
|
-
|
|
4
|
-
export default ts.config(
|
|
5
|
-
...workspaceConfig,
|
|
6
|
-
{
|
|
7
|
-
ignores: [
|
|
8
|
-
"src/scripts/*",
|
|
9
|
-
"src/server.js", // TODO: convert to src/server.ts and remove this ignore
|
|
10
|
-
],
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
languageOptions: {
|
|
14
|
-
parserOptions: { tsconfigRootDir: import.meta.dirname },
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
)
|
package/src/api/createApi.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type FetchArgs,
|
|
3
|
-
createApi as _createApi,
|
|
4
|
-
fetchBaseQuery,
|
|
5
|
-
} from "@reduxjs/toolkit/query/react"
|
|
6
|
-
|
|
7
|
-
import { SERVICE_API_URL } from "../settings"
|
|
8
|
-
import { buildLogoutEndpoint } from "./endpoints/session"
|
|
9
|
-
import defaultTagTypes from "./tagTypes"
|
|
10
|
-
import { getCsrfCookie } from "../utils/auth"
|
|
11
|
-
import { isSafeHttpMethod } from "../utils/api"
|
|
12
|
-
|
|
13
|
-
// TODO: decide if we want to keep any of this.
|
|
14
|
-
// export function handleResponseError(error: FetchBaseQueryError): void {
|
|
15
|
-
// if (
|
|
16
|
-
// error.status === 400 &&
|
|
17
|
-
// typeof error.data === "object" &&
|
|
18
|
-
// error.data !== null
|
|
19
|
-
// ) {
|
|
20
|
-
// // Parse the error's data from snake_case to camelCase.
|
|
21
|
-
// snakeCaseToCamelCase(error.data)
|
|
22
|
-
// } else if (error.status === 401) {
|
|
23
|
-
// // TODO: redirect to appropriate login page based on user type.
|
|
24
|
-
// window.location.href = `${PORTAL_BASE_URL}/login/teacher`
|
|
25
|
-
// } else {
|
|
26
|
-
// // Catch-all error pages by status-code.
|
|
27
|
-
// window.location.href = `${PORTAL_BASE_URL}/error/${
|
|
28
|
-
// [403, 404].includes(error.status as number) ? error.status : 500
|
|
29
|
-
// }`
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
export default function createApi<TagTypes extends string = never>({
|
|
34
|
-
tagTypes = [],
|
|
35
|
-
}: {
|
|
36
|
-
tagTypes?: readonly TagTypes[]
|
|
37
|
-
} = {}) {
|
|
38
|
-
const fetch = fetchBaseQuery({
|
|
39
|
-
baseUrl: `${SERVICE_API_URL}/`,
|
|
40
|
-
credentials: "include",
|
|
41
|
-
prepareHeaders: (headers, endpoint) => {
|
|
42
|
-
const { type, arg } = endpoint as typeof endpoint & {
|
|
43
|
-
arg: string | FetchArgs
|
|
44
|
-
}
|
|
45
|
-
const method = typeof arg === "string" ? "GET" : arg.method || "GET"
|
|
46
|
-
|
|
47
|
-
if (type === "mutation" || !isSafeHttpMethod(method)) {
|
|
48
|
-
const csrfToken = getCsrfCookie()
|
|
49
|
-
if (csrfToken) headers.set("x-csrftoken", csrfToken)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return headers
|
|
53
|
-
},
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
const api = _createApi({
|
|
57
|
-
// https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery
|
|
58
|
-
baseQuery: async (args: string | FetchArgs, api, extraOptions) => {
|
|
59
|
-
if (api.type === "mutation" && getCsrfCookie() === undefined) {
|
|
60
|
-
// Get the CSRF token.
|
|
61
|
-
const { error } = await fetch(
|
|
62
|
-
{ url: "/csrf/cookie/", method: "GET" },
|
|
63
|
-
api,
|
|
64
|
-
{},
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
// Validate we got the CSRF token.
|
|
68
|
-
if (error !== undefined) {
|
|
69
|
-
console.error(error)
|
|
70
|
-
// TODO
|
|
71
|
-
// window.location.href = `${PORTAL_BASE_URL}/error/500`
|
|
72
|
-
}
|
|
73
|
-
if (getCsrfCookie() === undefined) {
|
|
74
|
-
// TODO
|
|
75
|
-
// window.location.href = `${PORTAL_BASE_URL}/error/500`
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Send the HTTP request and fetch the response.
|
|
80
|
-
return await fetch(args, api, extraOptions)
|
|
81
|
-
},
|
|
82
|
-
tagTypes: [...defaultTagTypes, ...tagTypes],
|
|
83
|
-
endpoints: () => ({}),
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
return api.injectEndpoints({
|
|
87
|
-
endpoints: build => ({
|
|
88
|
-
logout: buildLogoutEndpoint<null, null>(api, build),
|
|
89
|
-
}),
|
|
90
|
-
})
|
|
91
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type ListArg as _ListArg,
|
|
5
|
-
type ListResult as _ListResult,
|
|
6
|
-
buildUrl,
|
|
7
|
-
tagData,
|
|
8
|
-
} from "../../utils/api"
|
|
9
|
-
import type { AuthFactor } from "../models"
|
|
10
|
-
import { type TagTypes } from "../tagTypes"
|
|
11
|
-
import urls from "../urls"
|
|
12
|
-
|
|
13
|
-
export const AUTH_FACTOR_TAG: TagTypes = "AuthFactor"
|
|
14
|
-
|
|
15
|
-
export type ListAuthFactorsResult = _ListResult<AuthFactor, "type">
|
|
16
|
-
export type ListAuthFactorsArg = _ListArg
|
|
17
|
-
|
|
18
|
-
export default function getReadAuthFactorEndpoints<
|
|
19
|
-
ListResult extends _ListResult<AuthFactor> = ListAuthFactorsResult,
|
|
20
|
-
ListArg extends _ListArg<AuthFactor> = ListAuthFactorsArg,
|
|
21
|
-
>(build: EndpointBuilder<any, any, any>) {
|
|
22
|
-
return {
|
|
23
|
-
listAuthFactors: build.query<ListResult, ListArg>({
|
|
24
|
-
query: search => ({
|
|
25
|
-
url: buildUrl(urls.authFactor.list, { search }),
|
|
26
|
-
method: "GET",
|
|
27
|
-
}),
|
|
28
|
-
providesTags: tagData(AUTH_FACTOR_TAG, { includeListTag: true }),
|
|
29
|
-
}),
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./authFactor"
|
|
2
|
-
export { default as getReadAuthFactorEndpoints } from "./authFactor"
|
|
3
|
-
export * from "./klass"
|
|
4
|
-
export { default as getReadClassEndpoints } from "./klass"
|
|
5
|
-
export * from "./school"
|
|
6
|
-
export { default as getReadSchoolEndpoints } from "./school"
|
|
7
|
-
export * from "./session"
|
|
8
|
-
export * from "./user"
|
|
9
|
-
export { default as getReadUserEndpoints } from "./user"
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
Class,
|
|
5
|
-
SchoolTeacher,
|
|
6
|
-
SchoolTeacherUser,
|
|
7
|
-
Teacher,
|
|
8
|
-
} from "../models"
|
|
9
|
-
import {
|
|
10
|
-
type ListArg as _ListArg,
|
|
11
|
-
type ListResult as _ListResult,
|
|
12
|
-
type RetrieveArg as _RetrieveArg,
|
|
13
|
-
type RetrieveResult as _RetrieveResult,
|
|
14
|
-
buildUrl,
|
|
15
|
-
tagData,
|
|
16
|
-
} from "../../utils/api"
|
|
17
|
-
import { type TagTypes } from "../tagTypes"
|
|
18
|
-
import urls from "../urls"
|
|
19
|
-
|
|
20
|
-
export const CLASS_TAG: TagTypes = "Class"
|
|
21
|
-
|
|
22
|
-
export type RetrieveClassResult = _RetrieveResult<
|
|
23
|
-
Class,
|
|
24
|
-
"name" | "read_classmates_data" | "receive_requests_until" | "school"
|
|
25
|
-
> & {
|
|
26
|
-
teacher: SchoolTeacher & {
|
|
27
|
-
user: Pick<
|
|
28
|
-
SchoolTeacherUser,
|
|
29
|
-
| "id"
|
|
30
|
-
| "first_name"
|
|
31
|
-
| "last_name"
|
|
32
|
-
| "email"
|
|
33
|
-
| "is_active"
|
|
34
|
-
| "date_joined"
|
|
35
|
-
| "requesting_to_join_class"
|
|
36
|
-
>
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export type RetrieveClassArg = _RetrieveArg<Class>
|
|
40
|
-
|
|
41
|
-
export type ListClassesResult = _ListResult<
|
|
42
|
-
Class,
|
|
43
|
-
"name" | "read_classmates_data" | "receive_requests_until" | "school",
|
|
44
|
-
{
|
|
45
|
-
teacher: SchoolTeacher & {
|
|
46
|
-
user: Pick<
|
|
47
|
-
SchoolTeacherUser,
|
|
48
|
-
| "id"
|
|
49
|
-
| "first_name"
|
|
50
|
-
| "last_name"
|
|
51
|
-
| "email"
|
|
52
|
-
| "is_active"
|
|
53
|
-
| "date_joined"
|
|
54
|
-
| "requesting_to_join_class"
|
|
55
|
-
>
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
>
|
|
59
|
-
export type ListClassesArg = _ListArg<{
|
|
60
|
-
teacher: Teacher["id"]
|
|
61
|
-
_id: Class["id"] | Class["id"][]
|
|
62
|
-
id_or_name: string
|
|
63
|
-
}>
|
|
64
|
-
|
|
65
|
-
export default function getReadClassEndpoints<
|
|
66
|
-
RetrieveResult extends _RetrieveResult<Class> = RetrieveClassResult,
|
|
67
|
-
RetrieveArg extends _RetrieveArg<Class> = RetrieveClassArg,
|
|
68
|
-
ListResult extends _ListResult<Class> = ListClassesResult,
|
|
69
|
-
ListArg extends _ListArg<Class> = ListClassesArg,
|
|
70
|
-
>(build: EndpointBuilder<any, any, any>) {
|
|
71
|
-
return {
|
|
72
|
-
retrieveClass: build.query<RetrieveResult, RetrieveArg>({
|
|
73
|
-
query: id => ({
|
|
74
|
-
url: buildUrl(urls.class.detail, { url: { id } }),
|
|
75
|
-
method: "GET",
|
|
76
|
-
}),
|
|
77
|
-
providesTags: tagData(CLASS_TAG),
|
|
78
|
-
}),
|
|
79
|
-
listClasses: build.query<ListResult, ListArg>({
|
|
80
|
-
query: search => ({
|
|
81
|
-
url: buildUrl(urls.class.list, { search }),
|
|
82
|
-
method: "GET",
|
|
83
|
-
}),
|
|
84
|
-
providesTags: tagData(CLASS_TAG, { includeListTag: true }),
|
|
85
|
-
}),
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
type RetrieveArg as _RetrieveArg,
|
|
5
|
-
type RetrieveResult as _RetrieveResult,
|
|
6
|
-
buildUrl,
|
|
7
|
-
tagData,
|
|
8
|
-
} from "../../utils/api"
|
|
9
|
-
import type { School } from "../models"
|
|
10
|
-
import { type TagTypes } from "../tagTypes"
|
|
11
|
-
import urls from "../urls"
|
|
12
|
-
|
|
13
|
-
export const SCHOOL_TAG: TagTypes = "School"
|
|
14
|
-
|
|
15
|
-
export type RetrieveSchoolResult = _RetrieveResult<
|
|
16
|
-
School,
|
|
17
|
-
"name" | "country" | "uk_county"
|
|
18
|
-
>
|
|
19
|
-
export type RetrieveSchoolArg = _RetrieveArg<School>
|
|
20
|
-
|
|
21
|
-
export default function getReadSchoolEndpoints<
|
|
22
|
-
RetrieveResult extends _RetrieveResult<School> = RetrieveSchoolResult,
|
|
23
|
-
RetrieveArg extends _RetrieveArg<School> = RetrieveSchoolArg,
|
|
24
|
-
>(build: EndpointBuilder<any, any, any>) {
|
|
25
|
-
return {
|
|
26
|
-
retrieveSchool: build.query<RetrieveResult, RetrieveArg>({
|
|
27
|
-
query: id => ({
|
|
28
|
-
url: buildUrl(urls.school.detail, { url: { id } }),
|
|
29
|
-
method: "GET",
|
|
30
|
-
}),
|
|
31
|
-
providesTags: tagData(SCHOOL_TAG),
|
|
32
|
-
}),
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type Api, type EndpointBuilder } from "@reduxjs/toolkit/query/react"
|
|
2
|
-
|
|
3
|
-
import { login, logout } from "../../slices/session"
|
|
4
|
-
|
|
5
|
-
export type ExchangeOAuth2CodeArg = {
|
|
6
|
-
code: string
|
|
7
|
-
code_verifier: string
|
|
8
|
-
redirect_uri: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function buildLoginEndpoint<ResultType, QueryArg>(
|
|
12
|
-
build: EndpointBuilder<any, any, any>,
|
|
13
|
-
url: string = "session/login/",
|
|
14
|
-
) {
|
|
15
|
-
return build.mutation<ResultType, QueryArg>({
|
|
16
|
-
query: body => ({ url, method: "POST", body }),
|
|
17
|
-
async onQueryStarted(_, { dispatch, queryFulfilled }) {
|
|
18
|
-
try {
|
|
19
|
-
await queryFulfilled
|
|
20
|
-
dispatch(login())
|
|
21
|
-
} catch (error) {
|
|
22
|
-
console.error("Failed to call login endpoint...", error)
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
})
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function buildLogoutEndpoint<ResultType, QueryArg>(
|
|
29
|
-
api: Api<any, any, any, any, any>,
|
|
30
|
-
build: EndpointBuilder<any, any, any>,
|
|
31
|
-
url: string = "session/logout/",
|
|
32
|
-
) {
|
|
33
|
-
return build.mutation<ResultType, QueryArg>({
|
|
34
|
-
query: () => ({ url, method: "POST" }),
|
|
35
|
-
async onQueryStarted(_, { dispatch, queryFulfilled }) {
|
|
36
|
-
try {
|
|
37
|
-
await queryFulfilled
|
|
38
|
-
} catch (error) {
|
|
39
|
-
console.error("Failed to call logout endpoint...", error)
|
|
40
|
-
} finally {
|
|
41
|
-
dispatch(logout())
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
43
|
-
dispatch(api.util.resetApiState())
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
})
|
|
47
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { type EndpointBuilder } from "@reduxjs/toolkit/query/react"
|
|
2
|
-
|
|
3
|
-
import type { Class, User } from "../models"
|
|
4
|
-
import {
|
|
5
|
-
type ListArg as _ListArg,
|
|
6
|
-
type ListResult as _ListResult,
|
|
7
|
-
type RetrieveArg as _RetrieveArg,
|
|
8
|
-
type RetrieveResult as _RetrieveResult,
|
|
9
|
-
buildUrl,
|
|
10
|
-
tagData,
|
|
11
|
-
} from "../../utils/api"
|
|
12
|
-
import { type TagTypes } from "../tagTypes"
|
|
13
|
-
import urls from "../urls"
|
|
14
|
-
|
|
15
|
-
export const USER_TAG: TagTypes = "User"
|
|
16
|
-
|
|
17
|
-
export type RetrieveUserResult = _RetrieveResult<
|
|
18
|
-
User,
|
|
19
|
-
| "first_name"
|
|
20
|
-
| "last_name"
|
|
21
|
-
| "email"
|
|
22
|
-
| "is_active"
|
|
23
|
-
| "date_joined"
|
|
24
|
-
| "requesting_to_join_class"
|
|
25
|
-
| "student"
|
|
26
|
-
| "teacher"
|
|
27
|
-
>
|
|
28
|
-
export type RetrieveUserArg = _RetrieveArg<User>
|
|
29
|
-
|
|
30
|
-
export type ListUsersResult = _ListResult<
|
|
31
|
-
User,
|
|
32
|
-
| "first_name"
|
|
33
|
-
| "last_name"
|
|
34
|
-
| "email"
|
|
35
|
-
| "is_active"
|
|
36
|
-
| "date_joined"
|
|
37
|
-
| "requesting_to_join_class"
|
|
38
|
-
| "student"
|
|
39
|
-
| "teacher"
|
|
40
|
-
>
|
|
41
|
-
export type ListUsersArg = _ListArg<{
|
|
42
|
-
students_in_class: Class["id"]
|
|
43
|
-
_id: User["id"] | User["id"][]
|
|
44
|
-
name: string
|
|
45
|
-
type: "teacher" | "student" | "independent" | "indy"
|
|
46
|
-
}>
|
|
47
|
-
|
|
48
|
-
export default function getReadUserEndpoints<
|
|
49
|
-
RetrieveResult extends _RetrieveResult<User> = RetrieveUserResult,
|
|
50
|
-
RetrieveArg extends _RetrieveArg<User> = RetrieveUserArg,
|
|
51
|
-
ListResult extends _ListResult<User> = ListUsersResult,
|
|
52
|
-
ListArg extends _ListArg<User> = ListUsersArg,
|
|
53
|
-
>(build: EndpointBuilder<any, any, any>) {
|
|
54
|
-
return {
|
|
55
|
-
retrieveUser: build.query<RetrieveResult, RetrieveArg>({
|
|
56
|
-
query: id => ({
|
|
57
|
-
url: buildUrl(urls.user.detail, { url: { id } }),
|
|
58
|
-
method: "GET",
|
|
59
|
-
}),
|
|
60
|
-
providesTags: tagData(USER_TAG),
|
|
61
|
-
}),
|
|
62
|
-
listUsers: build.query<ListResult, ListArg>({
|
|
63
|
-
query: search => ({
|
|
64
|
-
url: buildUrl(urls.user.list, { search }),
|
|
65
|
-
method: "GET",
|
|
66
|
-
}),
|
|
67
|
-
providesTags: tagData(USER_TAG, { includeListTag: true }),
|
|
68
|
-
}),
|
|
69
|
-
}
|
|
70
|
-
}
|
package/src/api/index.ts
DELETED
package/src/api/models.ts
DELETED
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { CountryIsoCodes, UkCounties } from "../utils/general"
|
|
2
|
-
import type { Model } from "../utils/api"
|
|
3
|
-
|
|
4
|
-
// -----------------------------------------------------------------------------
|
|
5
|
-
// User Models
|
|
6
|
-
// -----------------------------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
type _UserTeacher<T extends Teacher> = Omit<T, "user">
|
|
9
|
-
type _UserStudent<S extends Student> = Omit<S, "user" | "auto_gen_password">
|
|
10
|
-
|
|
11
|
-
export type User = Model<
|
|
12
|
-
number,
|
|
13
|
-
{
|
|
14
|
-
password: string
|
|
15
|
-
last_login?: Date
|
|
16
|
-
first_name: string
|
|
17
|
-
last_name?: string
|
|
18
|
-
email?: string
|
|
19
|
-
is_staff: boolean
|
|
20
|
-
is_active: boolean
|
|
21
|
-
date_joined: Date
|
|
22
|
-
requesting_to_join_class?: Class["id"] | null
|
|
23
|
-
teacher?: _UserTeacher<Teacher>
|
|
24
|
-
student?: _UserStudent<Student>
|
|
25
|
-
}
|
|
26
|
-
>
|
|
27
|
-
|
|
28
|
-
export type TeacherUser<Fields = User> = Fields & {
|
|
29
|
-
email: string
|
|
30
|
-
last_name: string
|
|
31
|
-
teacher: _UserTeacher<Teacher>
|
|
32
|
-
student?: undefined
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type SchoolTeacherUser<Fields = User> = TeacherUser<Fields> & {
|
|
36
|
-
teacher: _UserTeacher<SchoolTeacher>
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export type AdminSchoolTeacherUser<Fields = User> =
|
|
40
|
-
SchoolTeacherUser<Fields> & {
|
|
41
|
-
teacher: _UserTeacher<AdminSchoolTeacher>
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export type NonAdminSchoolTeacherUser<Fields = User> =
|
|
45
|
-
SchoolTeacherUser<Fields> & {
|
|
46
|
-
teacher: _UserTeacher<NonAdminSchoolTeacher>
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export type NonSchoolTeacherUser<Fields = User> = TeacherUser<Fields> & {
|
|
50
|
-
teacher: _UserTeacher<NonSchoolTeacher>
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export type StudentUser<Fields = User> = Fields & {
|
|
54
|
-
email?: undefined
|
|
55
|
-
last_name?: undefined
|
|
56
|
-
teacher?: undefined
|
|
57
|
-
student: _UserStudent<Student>
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type IndependentUser<Fields = User> = Fields & {
|
|
61
|
-
email: string
|
|
62
|
-
last_name: string
|
|
63
|
-
teacher?: undefined
|
|
64
|
-
student?: undefined
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// -----------------------------------------------------------------------------
|
|
68
|
-
// Teacher Models
|
|
69
|
-
// -----------------------------------------------------------------------------
|
|
70
|
-
|
|
71
|
-
export type Teacher = Model<
|
|
72
|
-
number,
|
|
73
|
-
{
|
|
74
|
-
user: User["id"]
|
|
75
|
-
school?: School["id"]
|
|
76
|
-
is_admin: boolean
|
|
77
|
-
}
|
|
78
|
-
>
|
|
79
|
-
|
|
80
|
-
export type SchoolTeacher<Fields = Teacher> = Fields & {
|
|
81
|
-
school: School["id"]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type AdminSchoolTeacher<Fields = Teacher> = SchoolTeacher<Fields> & {
|
|
85
|
-
is_admin: true
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type NonAdminSchoolTeacher<Fields = Teacher> = SchoolTeacher<Fields> & {
|
|
89
|
-
is_admin: false
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export type NonSchoolTeacher<Fields = Teacher> = Fields & {
|
|
93
|
-
school?: undefined
|
|
94
|
-
is_admin: false
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// -----------------------------------------------------------------------------
|
|
98
|
-
// Other Models
|
|
99
|
-
// -----------------------------------------------------------------------------
|
|
100
|
-
|
|
101
|
-
export type Student = Model<
|
|
102
|
-
number,
|
|
103
|
-
{
|
|
104
|
-
user: User["id"]
|
|
105
|
-
school: School["id"]
|
|
106
|
-
klass: Class["id"]
|
|
107
|
-
auto_gen_password: string
|
|
108
|
-
}
|
|
109
|
-
>
|
|
110
|
-
|
|
111
|
-
export type School = Model<
|
|
112
|
-
number,
|
|
113
|
-
{
|
|
114
|
-
name: string
|
|
115
|
-
country?: CountryIsoCodes
|
|
116
|
-
uk_county?: UkCounties
|
|
117
|
-
}
|
|
118
|
-
>
|
|
119
|
-
|
|
120
|
-
export type Class = Model<
|
|
121
|
-
string,
|
|
122
|
-
{
|
|
123
|
-
name: string
|
|
124
|
-
teacher: Teacher["id"]
|
|
125
|
-
school: School["id"]
|
|
126
|
-
read_classmates_data: boolean
|
|
127
|
-
receive_requests_until?: Date
|
|
128
|
-
}
|
|
129
|
-
>
|
|
130
|
-
|
|
131
|
-
export type AuthFactor = Model<
|
|
132
|
-
number,
|
|
133
|
-
{
|
|
134
|
-
user: User["id"]
|
|
135
|
-
type: "otp"
|
|
136
|
-
}
|
|
137
|
-
>
|
|
138
|
-
|
|
139
|
-
export type OtpBypassToken = Model<
|
|
140
|
-
number,
|
|
141
|
-
{
|
|
142
|
-
user: User["id"]
|
|
143
|
-
token: string
|
|
144
|
-
}
|
|
145
|
-
>
|