-
Notifications
You must be signed in to change notification settings - Fork 0
Created admin login UI component #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import AdminLogin from "@/app/user/admin/_components/AdminLogin"; | ||
| export default function AdminPage() { | ||
| return <></>; | ||
| return (<AdminLogin />); | ||
| } |
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The AdminLogin should be its own page. Admin.page.tsx should be the Admin home page. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| import { Button, PasswordInput, TextInput } from "@mantine/core"; | ||
| import { useState, type FormEvent } from "react"; | ||
|
|
||
| export default function AdminLogin() { | ||
| const [email, setEmail] = useState(""); | ||
| const [password, setPassword] = useState(""); | ||
|
|
||
| const [errors, setErrors] = useState({ | ||
| email: "", | ||
| password: "", | ||
| }); | ||
|
|
||
| const handleSubmit = (event: FormEvent<HTMLFormElement>) => { | ||
| event.preventDefault(); | ||
|
|
||
| const newErrors = { | ||
| email: "", | ||
| password: "", | ||
| }; | ||
|
|
||
| if (!email.trim()) { | ||
| newErrors.email = "Email is required"; | ||
| } | ||
|
|
||
| if (!password.trim()) { | ||
| newErrors.password = "Password is required"; | ||
| } | ||
|
|
||
| setErrors(newErrors); | ||
|
|
||
| if (newErrors.email || newErrors.password) { | ||
| return; | ||
| } | ||
|
|
||
| // Login handler is not in scope for this ticket. | ||
| console.log("Admin login submitted", { email, password }); | ||
| }; | ||
|
|
||
| return ( | ||
| <div | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use Mantine Box and Flex, which wrap the basic HTML divs. |
||
| style={{ | ||
| minHeight: "100vh", | ||
| width: "100vw", | ||
| backgroundColor: "white", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You shouldn't need to set the color of the entire page here. We can just use the theming to do it. |
||
| color: "black", | ||
| position: "relative", | ||
| }} | ||
| > | ||
| <header | ||
| style={{ | ||
| position: "absolute", | ||
| top: "24px", | ||
| left: "24px", | ||
| display: "flex", | ||
| alignItems: "center", | ||
| gap: "16px", | ||
| }} | ||
| > | ||
| <div | ||
| style={{ | ||
| width: "56px", | ||
| height: "56px", | ||
| backgroundColor: "white", | ||
| color: "black", | ||
| display: "flex", | ||
| alignItems: "center", | ||
| justifyContent: "center", | ||
| fontSize: "12px", | ||
| }} | ||
| > | ||
| logo | ||
| </div> | ||
| <h1 style={{ fontSize: "36px", fontWeight: 700, color: "black" }}>PatChats</h1> | ||
| </header> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The header should be broken out into its own component. It should also likely be reused across pages. You can look at We don't have to go to that extent right now, but yeah. |
||
| <div | ||
| style={{ | ||
| minHeight: "100vh", | ||
| display: "flex", | ||
| justifyContent: "center", | ||
| alignItems: "flex-start", | ||
| paddingTop: "220px", | ||
| }} | ||
| > | ||
| <form | ||
| onSubmit={handleSubmit} | ||
| style={{ | ||
| width: "250px", | ||
| }} | ||
| > | ||
| <h2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the Title component in mantine for html headers. |
||
| style={{ | ||
| textAlign: "center", | ||
| fontSize: "32px", | ||
| fontWeight: 400, | ||
| marginBottom: "20px", | ||
| color: "black", | ||
| }} | ||
| > | ||
| Admin Log in | ||
| </h2> | ||
| <TextInput | ||
| placeholder="Admin email" | ||
| value={email} | ||
| onChange={(event) => setEmail(event.currentTarget.value)} | ||
| error={errors.email} | ||
| radius="md" | ||
| size="sm" | ||
| mb="md" | ||
| styles={{ | ||
| input: { | ||
| backgroundColor: "#d1d1d1", | ||
| color: "black", | ||
| border: "none", | ||
| }, | ||
| }} | ||
| /> | ||
| <PasswordInput | ||
| placeholder="Password" | ||
| value={password} | ||
| onChange={(event) => setPassword(event.currentTarget.value)} | ||
| error={errors.password} | ||
| radius="md" | ||
| size="sm" | ||
| mb="lg" | ||
| styles={{ | ||
| input: { | ||
| backgroundColor: "#d1d1d1", | ||
| color: "black", | ||
| border: "none", | ||
| }, | ||
| innerInput: { | ||
| color: "black", | ||
| }, | ||
| }} | ||
| /> | ||
| <Button | ||
| type="submit" | ||
| fullWidth | ||
| radius="md" | ||
| size="sm" | ||
| styles={{ | ||
| root: { | ||
| backgroundColor: "#a94700", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably just lean into the provided styles from the mantine theme. |
||
| height: "42px", | ||
| }, | ||
| }} | ||
| > | ||
| Admin Log in | ||
| </Button> | ||
| </form> | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The admin stuff shouldn't be under js/src/app/user/admin, but should be under js/src/app/admin