-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
132 additions
and
29 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { type FC, useEffect } from "react" | ||
import * as yup from "yup" | ||
|
||
import * as page from "codeforlife/components/page" | ||
import { useNavigate, useParams, useSearchParams } from "codeforlife/hooks" | ||
Check failure on line 5 in src/pages/emailVerification/EmailVerification.tsx GitHub Actions / main / test / test-js-code
Check failure on line 5 in src/pages/emailVerification/EmailVerification.tsx GitHub Actions / main / test / test-js-code
Check failure on line 5 in src/pages/emailVerification/EmailVerification.tsx GitHub Actions / main / test / test-js-code
Check failure on line 5 in src/pages/emailVerification/EmailVerification.tsx GitHub Actions / main / test / test-js-code
Check failure on line 5 in src/pages/emailVerification/EmailVerification.tsx GitHub Actions / main / test / test-js-code
|
||
|
||
import PaperPlaneImg from "../../images/paper_plane.png" | ||
import SadFaceImg from "../../images/sadface.png" | ||
import { paths } from "../../router" | ||
import Status from "./Status" | ||
|
||
export interface EmailVerificationProps {} | ||
|
||
const EmailVerification: FC<EmailVerificationProps> = () => { | ||
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 ( | ||
<page.Page> | ||
<page.Section maxWidth="md" className="flex-center"> | ||
{searchParams?.success ? ( | ||
<Status | ||
userType={params.userType} | ||
header="We need to verify your email address" | ||
body={[ | ||
"An email has been sent to the address you provided.", | ||
"Please follow the link within the email to verify your details. This will expire in 1 hour.", | ||
"If you don't receive the email within the next few minutes, check your spam folder.", | ||
]} | ||
imageProps={{ | ||
alt: "PaperPlane", | ||
src: PaperPlaneImg, | ||
}} | ||
/> | ||
) : ( | ||
<Status | ||
userType={params.userType} | ||
header="Your email address verification failed" | ||
body={[ | ||
"You used an invalid link, either you mistyped the URL or that link is expired.", | ||
"When you next attempt to log in, you will be sent a new verification email.", | ||
]} | ||
imageProps={{ | ||
alt: "SadFace", | ||
src: SadFaceImg, | ||
}} | ||
/> | ||
)} | ||
</page.Section> | ||
</page.Page> | ||
) | ||
} | ||
|
||
export default EmailVerification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<StatusProps> = ({ userType, header, body, imageProps }) => ( | ||
<ThemedBox withShapes options={themeOptions} userType={userType}> | ||
<Stack alignItems="center"> | ||
<Typography variant="h4" paddingY={1} textAlign="center"> | ||
{header} | ||
</Typography> | ||
<Image maxWidth="100px" marginY={5} {...imageProps} /> | ||
<Stack> | ||
{body.map((text, index) => ( | ||
<Typography key={index}>{text}</Typography> | ||
))} | ||
</Stack> | ||
<LinkButton to={paths._} style={{ marginTop: 30 }}> | ||
Back to homepage | ||
</LinkButton> | ||
</Stack> | ||
</ThemedBox> | ||
) | ||
|
||
export default Status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters