Skip to content
Draft
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
7 changes: 5 additions & 2 deletions client/src/menus/AuthScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useState } from "react";
import { RegisterUserForm } from "./RegisterUserForm";
import { LoginUserForm } from "./LoginUserForm";

Expand All @@ -10,10 +11,12 @@ export function AuthScreen({
setShowRegister: (v: boolean) => void;
setHasJwt: (v: boolean) => void;
}) {
const [name, setName] = useState("");

if (showRegister) {
return (
<>
<RegisterUserForm onRegister={() => setHasJwt(true)} />
<RegisterUserForm onRegister={() => setHasJwt(true)} name={name} setName={setName} />
<div style={{ textAlign: "center", marginTop: 16 }}>
<span>
Already have an account?{" "}
Expand All @@ -38,7 +41,7 @@ export function AuthScreen({
} else {
return (
<>
<LoginUserForm onLogin={() => setHasJwt(true)} />
<LoginUserForm onLogin={() => setHasJwt(true)} name={name} setName={setName} />
<div style={{ textAlign: "center", marginTop: 16 }}>
<span>
Don&apos;t have an account?{" "}
Expand Down
11 changes: 9 additions & 2 deletions client/src/menus/LoginUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ const ButtonRow = styled.div`
gap: 1rem;
`;

export const LoginUserForm = ({ onLogin }: { onLogin?: () => void }) => {
const [name, setName] = useState("");
export const LoginUserForm = ({
onLogin,
name,
setName,
}: {
onLogin?: () => void;
name: string;
setName: (v: string) => void;
}) => {
const [password, setPassword] = useState("");
const [error, setError] = useState<string | null>(null);
const [loggedIn, setLoggedIn] = useState(false);
Expand Down
5 changes: 4 additions & 1 deletion client/src/menus/RegisterUserForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ const ButtonRow = styled.div`

export const RegisterUserForm = ({
onRegister,
name,
setName,
}: {
onRegister?: () => void;
name: string;
setName: (v: string) => void;
}) => {
const [name, setName] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState<string | null>(null);
const { login } = useAuth();
Expand Down
26 changes: 3 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.