Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Jul 16, 2024
1 parent 3860cb4 commit c82b710
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 37 deletions.
8 changes: 5 additions & 3 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
VITE_API_BASE_URL=http://localhost:8000/api/
VITE_SERVICE_NAME=portal

# Links external sites.
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/
# Gmail.
VITE_GMAIL_FILTERS_PASSWORD_RESET_REQUEST="from:[email protected] subject:Password reset request"
VITE_GMAIL_FILTERS_EMAIL_VERIFICATION="from:[email protected] subject:Email verification"

# Links to external sites.
VITE_LINK_FEMALE_GRADUATES_IN_CS=https://www.wisecampaign.org.uk/core-stem-graduates-2019/

# TODO: determine which of these we need.
Expand Down
32 changes: 32 additions & 0 deletions src/components/OpenInEmailButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { MailOutline as MailOutlineIcon } from "@mui/icons-material"
import { Stack } from "@mui/material"
import { type FC } from "react"

import { LinkButton } from "codeforlife/components/router"

export interface OpenInEmailButtonsProps {
gmailFilters: string
}

const OpenInEmailButtons: FC<OpenInEmailButtonsProps> = ({ gmailFilters }) => {
return (

Check warning on line 12 in src/components/OpenInEmailButtons.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/OpenInEmailButtons.tsx#L11-L12

Added lines #L11 - L12 were not covered by tests
<Stack direction="row" spacing={5}>
<LinkButton
to={`https://mail.google.com/mail/#search/${encodeURIComponent(gmailFilters)}`}
target="_blank"
endIcon={<MailOutlineIcon />}
>
Open in Gmail
</LinkButton>
<LinkButton
to="https://outlook.live.com/mail/"
target="_blank"
endIcon={<MailOutlineIcon />}
>
Open in Outlook
</LinkButton>
</Stack>
)
}

export default OpenInEmailButtons
10 changes: 9 additions & 1 deletion src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import NewPasswordField, {
type NewPasswordFieldProps,
} from "./NewPasswordField"
import OpenInEmailButtons, {
type OpenInEmailButtonsProps,
} from "./OpenInEmailButtons"

export { NewPasswordField, type NewPasswordFieldProps }
export {
NewPasswordField,
OpenInEmailButtons,
type NewPasswordFieldProps,
type OpenInEmailButtonsProps,
}
19 changes: 4 additions & 15 deletions src/pages/emailVerification/EmailVerification.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
MailOutline as MailOutlineIcon,
Send as SendIcon,
SentimentVeryDissatisfied as SentimentVeryDissatisfiedIcon,
} from "@mui/icons-material"
Expand Down Expand Up @@ -50,20 +49,10 @@ const EmailVerification: FC<EmailVerificationProps> = () => {
"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 />,
},
]}
openInEmailButtonsProps={{
gmailFilters: import.meta.env
.VITE_GMAIL_FILTERS_EMAIL_VERIFICATION,
}}
/>
) : (
<Status
Expand Down
22 changes: 9 additions & 13 deletions src/pages/emailVerification/Status.tsx
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
import { Stack, Typography } from "@mui/material"
import { type FC, type ReactElement } from "react"

import {
Link,
LinkButton,
type LinkButtonProps,
} from "codeforlife/components/router"
import { Link } from "codeforlife/components/router"
import { ThemedBox, type ThemedBoxProps } from "codeforlife/theme"

import { themeOptions } from "../../app/theme"
import {
OpenInEmailButtons,
type OpenInEmailButtonsProps,
} from "../../components"
import { paths } from "../../router"

export interface StatusProps {
userType: ThemedBoxProps["userType"]
header: string
body: string[]
icon: ReactElement
buttonProps?: LinkButtonProps[]
openInEmailButtonsProps?: OpenInEmailButtonsProps
}

const Status: FC<StatusProps> = ({
userType,
header,
body,
icon,
buttonProps,
openInEmailButtonsProps,
}) => (
<ThemedBox withShapes options={themeOptions} userType={userType}>
<Stack alignItems="center" marginBottom={2.5}>
Expand All @@ -37,12 +37,8 @@ const Status: FC<StatusProps> = ({
<Typography key={index}>{text}</Typography>
))}
</Stack>
{buttonProps && (
<Stack direction="row" spacing={5}>
{buttonProps.map((props, index) => (
<LinkButton key={index} {...props} />
))}
</Stack>
{openInEmailButtonsProps && (
<OpenInEmailButtons {...openInEmailButtonsProps} />
)}
</Stack>
<Link to={paths._} className="back-to">
Expand Down
16 changes: 11 additions & 5 deletions src/pages/resetPassword/EmailForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { Stack, Typography } from "@mui/material"
import { type FC } from "react"

import * as form from "codeforlife/components/form"
import { LinkButton } from "codeforlife/components/router"
import { Link, LinkButton } from "codeforlife/components/router"

import { useLazyRequestPasswordResetQuery } from "../../api/user"
import { OpenInEmailButtons } from "../../components"
import { paths } from "../../router"

export interface EmailFormProps {}
Expand All @@ -18,12 +19,17 @@ const EmailForm: FC<EmailFormProps> = () => {
<Typography textAlign="center" variant="h4">
Thank you
</Typography>
<SendIcon color="white" sx={{ fontSize: "100px", marginY: 5 }} />
<Typography>
If you have entered a valid email address, you will receive a link
enabling you to reset your password.
If you have entered a valid email address, you will receive a link to
reset your password. Make sure to check your <strong>spam</strong>.
</Typography>
<LinkButton to={paths._}>Back to homepage</LinkButton>
<SendIcon color="white" sx={{ fontSize: "100px", marginY: 5 }} />
<OpenInEmailButtons
gmailFilters={import.meta.env.VITE_GMAIL_FILTERS_PASSWORD_RESET_REQUEST}
/>
<Link to={paths._} className="back-to">
homepage
</Link>
</Stack>
) : (
<Stack gap={1}>
Expand Down

0 comments on commit c82b710

Please sign in to comment.