-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add git lens * add page * feedback * delete images * merge from dev
- Loading branch information
Showing
10 changed files
with
252 additions
and
37 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
VITE_API_BASE_URL=http://localhost:8000/api/ | ||
VITE_SERVICE_NAME=portal | ||
|
||
VITE_LINK_OPEN_VERIFY_EMAIL_IN_GMAIL="https://mail.google.com/mail/#search/from%3Ano-reply%40info.codeforlife.education+subject%3AEmail+Verification" | ||
VITE_LINK_OPEN_VERIFY_EMAIL_IN_OUTLOOK=https://outlook.live.com/mail/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { | ||
MailOutline as MailOutlineIcon, | ||
Send as SendIcon, | ||
SentimentVeryDissatisfied as SentimentVeryDissatisfiedIcon, | ||
} from "@mui/icons-material" | ||
import { type SvgIconProps } from "@mui/material" | ||
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" | ||
|
||
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 <></> | ||
|
||
const svgIconProps: SvgIconProps = { | ||
color: "white", | ||
style: { fontSize: "100px" }, | ||
} | ||
|
||
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 you. Make sure to check your spam.", | ||
"Please follow the link within the email to verify your details. This will expire in 1 hour.", | ||
]} | ||
icon={<SendIcon {...svgIconProps} />} | ||
buttonProps={[ | ||
{ | ||
to: import.meta.env.VITE_LINK_OPEN_VERIFY_EMAIL_IN_GMAIL, | ||
target: "_blank", | ||
children: "Open in Gmail", | ||
endIcon: <MailOutlineIcon />, | ||
}, | ||
{ | ||
to: import.meta.env.VITE_LINK_OPEN_VERIFY_EMAIL_IN_OUTLOOK, | ||
target: "_blank", | ||
children: "Open in Outlook", | ||
endIcon: <MailOutlineIcon />, | ||
}, | ||
]} | ||
/> | ||
) : ( | ||
<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.", | ||
]} | ||
icon={<SentimentVeryDissatisfiedIcon {...svgIconProps} />} | ||
/> | ||
)} | ||
</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,54 @@ | ||
import { Stack, Typography } from "@mui/material" | ||
import { type FC, type ReactElement } from "react" | ||
|
||
import { | ||
Link, | ||
LinkButton, | ||
type LinkButtonProps, | ||
} 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[] | ||
icon: ReactElement | ||
buttonProps?: LinkButtonProps[] | ||
} | ||
|
||
const Status: FC<StatusProps> = ({ | ||
userType, | ||
header, | ||
body, | ||
icon, | ||
buttonProps, | ||
}) => ( | ||
<ThemedBox withShapes options={themeOptions} userType={userType}> | ||
<Stack alignItems="center" marginBottom={2.5}> | ||
<Typography variant="h4" paddingY={1} textAlign="center"> | ||
{header} | ||
</Typography> | ||
{icon} | ||
<Stack> | ||
{body.map((text, index) => ( | ||
<Typography key={index}>{text}</Typography> | ||
))} | ||
</Stack> | ||
{buttonProps && ( | ||
<Stack direction="row" spacing={5}> | ||
{buttonProps.map((props, index) => ( | ||
<LinkButton key={index} {...props} /> | ||
))} | ||
</Stack> | ||
)} | ||
</Stack> | ||
<Link to={paths._} className="back-to"> | ||
homepage | ||
</Link> | ||
</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
Oops, something went wrong.