diff --git a/src/api/client.ts b/src/api/client.ts index 6840c29..91c38e8 100644 --- a/src/api/client.ts +++ b/src/api/client.ts @@ -21,16 +21,21 @@ interface AccessResponse { jwtToken: string; } -export const login = async (name: string, password: string) => { +export const login = async (email: string, password: string) => { const response = (await axios.post("/access/login", { - name, + email, password, })) as AxiosResponse; setJwtToken(response.data.jwtToken); }; -export const registerUser = async (name: string, password: string) => { +export const registerUser = async ( + email: string, + name: string, + password: string, +) => { const response = (await axios.post("/access/register", { + email, name, password, })) as AxiosResponse; diff --git a/src/pages/auth/Login.tsx b/src/pages/auth/Login.tsx index be8de71..daf75ec 100644 --- a/src/pages/auth/Login.tsx +++ b/src/pages/auth/Login.tsx @@ -1,23 +1,15 @@ import { useState } from "react"; import { login } from "../../api/client"; import { useNavigate } from "react-router"; -import { - Button, - Checkbox, - FormControlLabel, - Grid, - TextField, - Typography, -} from "@mui/material"; +import { Button, Grid, TextField, Typography } from "@mui/material"; export const Login = () => { - const [userName, setUserName] = useState(""); + const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); - const [rememberMe, setRememberMe] = useState(false); const navigate = useNavigate(); const handleLoginFlow = () => - login(userName, password).then(() => { + login(email, password).then(() => { navigate("/signup"); }); @@ -25,9 +17,9 @@ export const Login = () => { Login setUserName(e.target.value)} - placeholder="User" + value={email} + onChange={(e) => setEmail(e.target.value)} + placeholder="Email" /> { onChange={(e) => setPassword(e.target.value)} placeholder="Password" /> - setRememberMe(!rememberMe)} - /> - } - label="Remember me" - /> - {!!passwordErrors.length && ( + {!!allErrors.length && ( { }} > - {passwordErrors.map((error) => ( + {allErrors.map((error) => ( {error} ))}