Skip to content

Commit

Permalink
Apply review changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SalmanAsh committed Sep 3, 2024
1 parent 85f0392 commit 35e75b9
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 110 deletions.
36 changes: 0 additions & 36 deletions src/components/GitHubLoginButton.tsx

This file was deleted.

Binary file removed src/images/github-mark-white.png
Binary file not shown.
81 changes: 73 additions & 8 deletions src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,22 +1,87 @@
import * as pages from "codeforlife/components/page"
import { type FC } from "react"
import * as yup from "yup"
import { type FC, useEffect } from "react"
import { GH_CLIENT_ID } from "../../app/env"
import GitHubIcon from "@mui/icons-material/GitHub"
import { Image } from "codeforlife/components"
import { Typography } from "@mui/material"
import { LinkButton } from "codeforlife/components/router"
import { paths } from "../../routes"

import { Stack, Typography } from "@mui/material"
import { useLoginWithGitHubMutation } from "../../api/session"
import { useNavigate } from "codeforlife/hooks/router"
import { useSearchParams } from "codeforlife/hooks/router"

import CflLogoImage from "../../images/cfl_logo.png"
import { useSessionMetadata } from "../../app/hooks"

export interface HomeProps {}

const Home: FC<HomeProps> = () => {
const [loginWithGitHub] = useLoginWithGitHubMutation()
const sessionMetadata = useSessionMetadata()
const navigate = useNavigate()
const searchParams = useSearchParams({
code: yup.string(),
})

useEffect(() => {
const code = searchParams?.code

if (sessionMetadata) {
navigate(paths.agreementSignatures._)
} else if (code) {
navigate(".", { replace: true })
searchParams.code = undefined

loginWithGitHub({ code })
.unwrap()
.then(() => {
navigate(paths.agreementSignatures._)
})
.catch(err => {
alert(`Login failed: ${err}`)
})
}
}, [sessionMetadata, loginWithGitHub, navigate, searchParams])

return (
<pages.Page>
<pages.Section>
<Image src={CflLogoImage} alt="code for life logo" maxWidth="200px" />
<Typography variant="h1">Example web page</Typography>
<Typography>
This is an example of how you can create a web page. This example
consumes the backend-template&apos;s API.
</Typography>
<Stack
spacing={10}
sx={{
display: "flex",
flexDirection: "column",
alignItems: "center",
textAlign: "center",
}}
>
<Image src={CflLogoImage} alt="code for life logo" maxWidth="200px" />
<Typography variant="h1">
Welcome to our Contributor Service!
</Typography>
<Typography>
We are excited to have you join the CFL community. As a contributor,
you have the opportunity to share your knowledge, insights, and
unique perspectives with a passionate audience. Dive in, start
contributing, and help us make a difference.
</Typography>
<LinkButton
to={`https://github.com/login/oauth/authorize?client_id=${GH_CLIENT_ID}`}
sx={theme => ({
marginTop: `${theme.spacing(20)}`,
borderRadius: `${theme.spacing(1)}`,
padding: `${theme.spacing(4)} ${theme.spacing(5)}`,
fontSize: `${theme.spacing(2.5)}`,
background: "black",
color: "white.main",
})}
startIcon={<GitHubIcon />}
>
Log in with GitHub
</LinkButton>
</Stack>
</pages.Section>
</pages.Page>
)
Expand Down
53 changes: 0 additions & 53 deletions src/pages/login/GitHub.tsx

This file was deleted.

12 changes: 0 additions & 12 deletions src/routes/login.tsx

This file was deleted.

1 change: 0 additions & 1 deletion src/routes/paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ const paths = _("", {
agreementSignatures: _("/agreement-signatures", {
id: _("/:id"),
}),
login: _("/login"),
})

export default paths

0 comments on commit 35e75b9

Please sign in to comment.