Skip to content

Commit

Permalink
new cfl package (#78)
Browse files Browse the repository at this point in the history
* new cfl package

* new cfl package
  • Loading branch information
SKairinos authored Oct 30, 2024
1 parent f8bfd33 commit 7a6c72c
Show file tree
Hide file tree
Showing 20 changed files with 1,032 additions and 1,099 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"✅ Do add `devDependencies` below that are `peerDependencies` in the CFL package."
],
"dependencies": {
"codeforlife": "github:ocadotechnology/codeforlife-package-javascript#v2.4.1",
"codeforlife": "github:ocadotechnology/codeforlife-package-javascript#v2.5.0",
"crypto-js": "^4.2.0"
},
"devDependencies": {
Expand Down
54 changes: 17 additions & 37 deletions src/api/sso.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "codeforlife/api"
import { type Arg } from "codeforlife/utils/api"
import { type SessionMetadata } from "codeforlife/hooks"
import { buildLoginEndpoint } from "codeforlife/api/endpoints"

import api from "."

Expand Down Expand Up @@ -35,47 +36,26 @@ export type AutoLoginAsStudentArg = {

const ssoApi = api.injectEndpoints({
endpoints: build => ({
loginWithEmail: build.mutation<LoginWithEmailResult, LoginWithEmailArg>({
query: body => ({
url: baseUrl + "login-with-email/",
method: "POST",
body,
}),
}),
loginWithOtp: build.mutation<LoginWithOtpResult, LoginWithOtpArg>({
query: body => ({
url: baseUrl + "login-with-otp/",
method: "POST",
body,
}),
}),
loginWithOtpBypassToken: build.mutation<
loginWithEmail: buildLoginEndpoint<LoginWithEmailResult, LoginWithEmailArg>(
build,
baseUrl + "login-with-email/",
),
loginWithOtp: buildLoginEndpoint<LoginWithOtpResult, LoginWithOtpArg>(
build,
baseUrl + "login-with-otp/",
),
loginWithOtpBypassToken: buildLoginEndpoint<
LoginWithOtpBypassTokenResult,
LoginWithOtpBypassTokenArg
>({
query: body => ({
url: baseUrl + "login-with-otp-bypass-token/",
method: "POST",
body,
}),
}),
loginAsStudent: build.mutation<LoginAsStudentResult, LoginAsStudentArg>({
query: body => ({
url: baseUrl + "login-as-student/",
method: "POST",
body,
}),
}),
autoLoginAsStudent: build.mutation<
>(build, baseUrl + "login-with-otp-bypass-token/"),
loginAsStudent: buildLoginEndpoint<LoginAsStudentResult, LoginAsStudentArg>(
build,
baseUrl + "login-as-student/",
),
autoLoginAsStudent: buildLoginEndpoint<
AutoLoginAsStudentResult,
AutoLoginAsStudentArg
>({
query: body => ({
url: baseUrl + "auto-login-as-student/",
method: "POST",
body,
}),
}),
>(build, baseUrl + "auto-login-as-student/"),
}),
})

Expand Down
4 changes: 2 additions & 2 deletions src/app/env.ts → src/app/settings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import env from "codeforlife/env"
import env from "codeforlife/settings"

export * from "codeforlife/env"
export * from "codeforlife/settings"

// Gmail.
export const GMAIL_FILTERS_PASSWORD_RESET_REQUEST =
Expand Down
9 changes: 7 additions & 2 deletions src/app/store.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
import type { Action, ThunkAction } from "@reduxjs/toolkit"
import { combineSlices } from "@reduxjs/toolkit"
import { logoutMiddleware } from "codeforlife/middlewares"
import { makeStore } from "codeforlife/utils/store"
import { sessionSlice } from "codeforlife/slices"

import api from "../api"

// `combineSlices` automatically combines the reducers using
// their `reducerPath`s, therefore we no longer need to call `combineReducers`.
const reducer = combineSlices(api)
const reducer = combineSlices(api, sessionSlice)

// Infer the `RootState` type from the root reducer
export type RootState = ReturnType<typeof reducer>

// TODO: create middleware for api errors.
// https://redux-toolkit.js.org/rtk-query/usage/error-handling#handling-errors-at-a-macro-level
const store = makeStore({ reducer, middlewares: [api.middleware] })
const store = makeStore({
reducer,
middlewares: [api.middleware, logoutMiddleware],
})

export default store
export type AppStore = typeof store
Expand Down
2 changes: 1 addition & 1 deletion src/components/OpenInEmailButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LinkButton } from "codeforlife/components/router"
import { MailOutline as MailOutlineIcon } from "@mui/icons-material"
import { Stack } from "@mui/material"

import { LINK_OUTLOOK_HOME } from "../app/env"
import { LINK_OUTLOOK_HOME } from "../app/settings"

export interface OpenInEmailButtonsProps {
gmailFilters: string
Expand Down
2 changes: 1 addition & 1 deletion src/features/footer/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { ThemedBox } from "codeforlife/theme"
import { primary } from "codeforlife/theme/colors"

import CFLPoweredLogoImage from "../../images/logo_cfl_powered.svg"
import { LINK_SKILLS_FOR_THE_FUTURE } from "../../app/env"
import { LINK_SKILLS_FOR_THE_FUTURE } from "../../app/settings.ts"
import Links from "./Links"
import RegisterToNewsletterForm from "./RegisterToNewsletterForm.tsx"
import SocialMediaIcons from "./SocialMediaIcons"
Expand Down
2 changes: 1 addition & 1 deletion src/features/footer/Links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
// useOneTrustInfoToggle
// } from 'codeforlife/hooks';
import { type FC } from "react"
import { LINK_IMPACT_REPORT_2023 } from "../../app/env"
import { LINK_IMPACT_REPORT_2023 } from "../../app/settings"
import { Link } from "codeforlife/components/router"

import { paths } from "../../routes"
Expand Down
2 changes: 1 addition & 1 deletion src/features/footer/SocialMediaIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
LINK_LINKEDIN,
LINK_X,
LINK_YOUTUBE,
} from "../../app/env"
} from "../../app/settings"

const SocialMediaIcon: FC<{
to: string
Expand Down
2 changes: 1 addition & 1 deletion src/pages/aboutUs/OcadoGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Typography } from "@mui/material"

import AboutUsOcadoImage from "../../images/about_us_ocado.jpg"
import Introduction from "../../components/Introduction"
import { LINK_SKILLS_FOR_THE_FUTURE } from "../../app/env"
import { LINK_SKILLS_FOR_THE_FUTURE } from "../../app/settings"

export interface OcadoGroupProps {}

Expand Down
2 changes: 1 addition & 1 deletion src/pages/aboutUs/Supporters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { type FC } from "react"
import { Image } from "codeforlife/components"
import { Link } from "codeforlife/components/router"

import { LINK_CFL_DOCS, LINK_PORTAL_GITHUB } from "../../app/env"
import { LINK_CFL_DOCS, LINK_PORTAL_GITHUB } from "../../app/settings"
import BarefootImage from "../../images/barefoot_logo.png"
import BcsImage from "../../images/bcs_logo.png"
import GLAImage from "../../images/gla_logo.png"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/codingClubs/Primary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Typography } from "@mui/material"
import {
LINK_PRIMARY_PACK_DOWNLOAD,
LINK_PRIMARY_PACK_GITBOOK,
} from "../../app/env"
} from "../../app/settings"
import AboutUsImage from "../../images/about_us.jpg"
import Introduction from "../../components/Introduction"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/codingClubs/Python.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
LINK_GRASS_SNAKES_CLUB_PACK,
LINK_PYTHON_PACK_GITBOOK,
LINK_TIGER_SNAKES_CLUB_PACK,
} from "../../app/env"
} from "../../app/settings"
import Introduction from "../../components/Introduction"
import PythonClubImage from "../../images/coding_club_python_pack.png"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/emailVerification/EmailVerification.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import { useNavigate, useParams, useSearchParams } from "codeforlife/hooks"
import { type SvgIconProps } from "@mui/material"

import { GMAIL_FILTERS_EMAIL_VERIFICATION } from "../../app/env"
import { GMAIL_FILTERS_EMAIL_VERIFICATION } from "../../app/settings"
import Status from "./Status"
import { paths } from "../../routes"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/AboutUs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Image } from "codeforlife/components"
import ControllerIconImage from "../../images/icon_controller.png"
import FreeIconImage from "../../images/icon_free.png"
import GlobeIconImage from "../../images/icon_globe.png"
import { LINK_FEMALE_GRADUATES_IN_CS } from "../../app/env"
import { LINK_FEMALE_GRADUATES_IN_CS } from "../../app/settings"
import PieChartIconImage from "../../images/icon_piechart.png"
import { paths } from "../../routes"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/homeLearning/Advanced.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC } from "react"

import { LINK_HOME_LEARNING_ADVANCED } from "../../app/env"
import { LINK_HOME_LEARNING_ADVANCED } from "../../app/settings"
import Levels from "./Levels"
import { Link } from "codeforlife/components/router"
import RRAdvancedImage from "../../images/rr_advanced.png"
Expand Down
2 changes: 1 addition & 1 deletion src/pages/homeLearning/Beginner.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC } from "react"

import { LINK_HOME_LEARNING_BEGINNER } from "../../app/env"
import { LINK_HOME_LEARNING_BEGINNER } from "../../app/settings"
import Levels from "./Levels"
import RRBeginnerImage from "../../images/rr_beginner.png"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/homeLearning/HomeLearning.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Advanced from "./Advanced"
import Beginner from "./Beginner"
import HomeLearningHeroImage from "../../images/home_learning_hero_hexagon.png"
import Intermediate from "./Intermediate"
import { LINK_IDEAS_BOX } from "../../app/env"
import { LINK_IDEAS_BOX } from "../../app/settings"
import { paths } from "../../routes"

export interface HomeLearningProps {}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/homeLearning/Intermediate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC } from "react"

import { LINK_HOME_LEARNING_INTERMEDIATE } from "../../app/env"
import { LINK_HOME_LEARNING_INTERMEDIATE } from "../../app/settings"
import Levels from "./Levels"
import RRIntermediateImage from "../../images/rr_intermediate.png"

Expand Down
2 changes: 1 addition & 1 deletion src/pages/resetPassword/EmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Stack, Typography } from "@mui/material"
import { type FC } from "react"
import { Send as SendIcon } from "@mui/icons-material"

import { GMAIL_FILTERS_PASSWORD_RESET_REQUEST } from "../../app/env"
import { GMAIL_FILTERS_PASSWORD_RESET_REQUEST } from "../../app/settings"
import { OpenInEmailButtons } from "../../components"
import { paths } from "../../routes"
import { useLazyRequestPasswordResetQuery } from "../../api/user"
Expand Down
Loading

0 comments on commit 7a6c72c

Please sign in to comment.