From 5ae4951afd5357a461da11260673f9035f5b9553 Mon Sep 17 00:00:00 2001 From: SKairinos Date: Fri, 5 Jul 2024 16:19:52 +0000 Subject: [PATCH] add page --- src/images/paper_plane.png | Bin 0 -> 2728 bytes src/images/sadface.png | Bin 0 -> 2148 bytes .../emailVerification/EmailVerification.tsx | 68 ++++++++++++++++++ src/pages/emailVerification/Status.tsx | 37 ++++++++++ src/pages/login/Login.tsx | 13 ++-- src/pages/login/studentForms/Class.tsx | 15 ++-- src/router/paths.ts | 7 +- src/router/routes/authentication.tsx | 11 ++- vite.config.ts | 10 ++- 9 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 src/images/paper_plane.png create mode 100644 src/images/sadface.png create mode 100644 src/pages/emailVerification/EmailVerification.tsx create mode 100644 src/pages/emailVerification/Status.tsx diff --git a/src/images/paper_plane.png b/src/images/paper_plane.png new file mode 100644 index 0000000000000000000000000000000000000000..6324bdf76591e42844019f94b93bc77629b71fcb GIT binary patch literal 2728 zcmV;Z3Rm@sP)z$+ISrEIM!0~6bTBf*_u3HT2b%LWqqZ&Pc|F~MFO-xEDXg3;gzps^@OzT?Kq zI#EIHNjV*IcBIPF!6M`m)XM^5AX;Ea6GS`WU z;w)KTWOsr*At#k2ofP$ z>zoG;23Cd-i>rjJq0v8po;fwdRN%AXa#j-sIa=Qw1T>`{2Ks_Z%9}L43}_Y^mn4dA z)nUe`1S^Sxp#9N(G#Cj6fvrI$MeCi(K>oZPbOUiky>W4IVQYwj9ECE?*7R%D;{@%! znIP|=#5Ld$@Bm0U)z`LB3+Nz569qYX;HE7cO{q@-TK||L8tm@^vw-xQ0~$e6S5d}Gl?V7cX0jGh%AkAkyRF_yZ7TthD7ozVaT+aq+kR-+09=+?rNWtKp!D#R# z_#K!iI&XIaXbW$AUIuhPGA-FiMS7HCmY~#jUypsBS z$KKpSABrfn^#nSVb0#oh)`l8^qOs_1FpE&PUb(R0az18&ZS_4x`LcMS>(-qcQ5e@m zqk6_8ax|^p379VPP*7u0VO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91O!9BV-AMX{s$q$cr)>&%{=ZX78?v> z0wXxj90Vt}mkXK3u*l|%gfo>#!;3g%ni7m{E%=+S9Tsf!Nm~p4#?4;pPYpg}y4j>_ z%8ud7^2}n?HD$-RD^BxQ$oy7~+a}#HYwm$pZN93~jhbj}raq^uz{wzVa8npRS9Q~7 z@$FBHd&FpkYNgF$zaL$98m37*0mA$D+#+N5cpMJQGftVfgF~bctRO4Rrw7+FHJuxxbF+9!S20fonoDsQUe#HE+wWvmFz#Cy$=Kfsj%DscS`82 z#aq72#sV-?15$M0Wb)W!f|uEO@VlqPLOBFTtiNqTZVBN~#q}90xn3ID&Dx|>q|fKc zytO_R9R*^an`|)8?V#K?DT@zzR^}_eD)C50e}jC2%tNqkspx2SuB*1fWK8TC4m*Py zZNl}(94Q)usk@IJIA`F0oaZ|~-pR(eLhuo0I@+ivx4^cdvKNS}X>a9FkcnIrX|v-hxQ&J~ zjw0Zl%rawX-YRV#2v>~3u_?hy;#-J5f`lPtQ({>p6fIvAttRF1BEZFeD44@aIm-5P zD`(}E%g*fqVh8;x)L{I=%uy#_3nENY zp@D@cPbP*-UCHjHD6$t+M1xiWG-71jZ2E43+iV3{DYB~?gZK5AUma-gHfNg0Mn1;b zsFx$zy_Ch}!y^HGmkz?n_^}`#nZpCKe==)tY4P%~YT1mjqeVgfJC9aw?h0f#cdfn0 zG}z#q!QuM<&IeqKUyJQ=!L;cY!+qE0$k79p1mm0Wz@fpp->-~+xHId*i`kW6aJIm+9w-m;$n8w9l1z%j-3cwwxd=|{uuDK}Qk^0lp#TLas@Q^(8gm`kF;Icaci4g5)IC1GNh17$z_&| zeS~UG(Re`Fb6jSes)t>QxoHu8bZVk==6a2;{5ziCAfZM492z# z{K;hw*XF+}wlj&E+6#h9O!)xG{*HuqsRO+~<`xM3KvI`J5!x$)YiN624PQ$)wQcc_ a00RJX_?|{m0`d<40000 = () => { + const navigate = useNavigate() + const params = useParams({ + userType: yup + .string() + .oneOf(["teacher", "independent"] as const) + .required(), + }) + const searchParams = useSearchParams({ + success: yup.boolean().required().default(true), + }) + + useEffect(() => { + if (!params) navigate(paths.error.pageNotFound._) + }, [params, navigate]) + + if (!params) return <> + + return ( + + + {searchParams?.success ? ( + + ) : ( + + )} + + + ) +} + +export default EmailVerification diff --git a/src/pages/emailVerification/Status.tsx b/src/pages/emailVerification/Status.tsx new file mode 100644 index 0000000..f142741 --- /dev/null +++ b/src/pages/emailVerification/Status.tsx @@ -0,0 +1,37 @@ +import { Stack, Typography } from "@mui/material" +import { type FC } from "react" + +import { Image, type ImageProps } from "codeforlife/components" +import { LinkButton } from "codeforlife/components/router" +import { ThemedBox, type ThemedBoxProps } from "codeforlife/theme" + +import { themeOptions } from "../../app/theme" +import { paths } from "../../router" + +export interface StatusProps { + userType: ThemedBoxProps["userType"] + header: string + body: string[] + imageProps: ImageProps +} + +const Status: FC = ({ userType, header, body, imageProps }) => ( + + + + {header} + + + + {body.map((text, index) => ( + {text} + ))} + + + Back to homepage + + + +) + +export default Status diff --git a/src/pages/login/Login.tsx b/src/pages/login/Login.tsx index 0bafb8b..ea03d1c 100644 --- a/src/pages/login/Login.tsx +++ b/src/pages/login/Login.tsx @@ -4,10 +4,9 @@ import * as yup from "yup" import * as page from "codeforlife/components/page" import { useNavigate, - useSearchParamEntries, + useSearchParams, useSessionMetadata, } from "codeforlife/hooks" -import { tryValidateSync } from "codeforlife/utils/schema" import { paths } from "../../router" import IndyForm from "./IndyForm" @@ -27,13 +26,9 @@ export interface LoginProps { const Login: FC = ({ form }) => { const sessionMetadata = useSessionMetadata() const navigate = useNavigate() - - const searchParams = tryValidateSync( - useSearchParamEntries(), - yup.object({ - verifyEmail: yup.boolean().default(false), - }), - ) + const searchParams = useSearchParams({ + verifyEmail: yup.boolean().default(false), + }) useEffect(() => { if (sessionMetadata) { diff --git a/src/pages/login/studentForms/Class.tsx b/src/pages/login/studentForms/Class.tsx index 9ff4e4e..1583249 100644 --- a/src/pages/login/studentForms/Class.tsx +++ b/src/pages/login/studentForms/Class.tsx @@ -5,8 +5,7 @@ import { generatePath } from "react-router-dom" import * as yup from "yup" import * as form from "codeforlife/components/form" -import { useNavigate, useSearchParamEntries } from "codeforlife/hooks" -import { tryValidateSync } from "codeforlife/utils/schema" +import { useNavigate, useSearchParams } from "codeforlife/hooks" import { useAutoLoginAsStudentMutation } from "../../../api/sso" import { classIdSchema } from "../../../app/schemas" @@ -18,14 +17,10 @@ export interface ClassProps {} const Class: FC = () => { const [autoLoginAsStudent] = useAutoLoginAsStudentMutation() const navigate = useNavigate() - - const searchParams = tryValidateSync( - useSearchParamEntries(), - yup.object({ - id: yup.number().required(), - agp: yup.string().required(), - }), - ) + const searchParams = useSearchParams({ + id: yup.number().required(), + agp: yup.string().required(), + }) useEffect(() => { if (searchParams) { diff --git a/src/router/paths.ts b/src/router/paths.ts index 327104d..b5b903a 100644 --- a/src/router/paths.ts +++ b/src/router/paths.ts @@ -55,9 +55,10 @@ const paths = _("", { }), register: _("/register", { emailVerification: _("/email-verification", { - teacher: _("/teacher"), - student: _("/student"), - indy: _("/independent"), + userType: _("/:userType", { + teacher: _({ userType: "teacher" }), + indy: _({ userType: "independent" }), + }), }), }), aboutUs: _("/about-us"), diff --git a/src/router/routes/authentication.tsx b/src/router/routes/authentication.tsx index df70e3b..f39086b 100644 --- a/src/router/routes/authentication.tsx +++ b/src/router/routes/authentication.tsx @@ -1,7 +1,6 @@ import { Route } from "react-router-dom" -// eslint-disable-next-line max-len -// import EmailVerification from '../../../pages/emailVerification/EmailVerification' +import EmailVerification from "../../pages/emailVerification/EmailVerification" import Login from "../../pages/login/Login" // import Register from '../../../pages/register/Register' // import ResetPassword from '../../../pages/resetPassword/ResetPassword' @@ -15,10 +14,6 @@ import paths from "../paths" // path={paths.register._} // element={} // /> -// } -// /> const authentication = ( <> @@ -43,6 +38,10 @@ const authentication = ( element={} /> } /> + } + /> ) diff --git a/vite.config.ts b/vite.config.ts index ca274c8..01e6878 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -26,6 +26,14 @@ export default defineConfig({ }, optimizeDeps: { // TODO: investigate which of these are needed - include: ["@mui/icons-material", "yup", "formik"], + include: [ + "@mui/x-date-pickers", + "@mui/x-date-pickers/AdapterDayjs", + "dayjs", + "dayjs/locale/en-gb", + "@mui/icons-material", + "yup", + "formik", + ], }, })