Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion js/src/app/user/admin/Admin.page.tsx

Copy link
Copy Markdown
Contributor

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

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 />);
}
154 changes: 154 additions & 0 deletions js/src/app/user/admin/_components/AdminLogin.tsx

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 js/src/components/ui/page/PageShell.tsx in codebloom to see how it's done there.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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>
);
}