From 733c817145dc0cd127a188581707be93a96d726a Mon Sep 17 00:00:00 2001 From: Paul Pan Date: Thu, 22 Feb 2024 18:47:18 +0800 Subject: [PATCH] feat: refine LoginPage --- src/pages/LoginPage.tsx | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/src/pages/LoginPage.tsx b/src/pages/LoginPage.tsx index ff4b4ff..f544dd8 100644 --- a/src/pages/LoginPage.tsx +++ b/src/pages/LoginPage.tsx @@ -51,10 +51,9 @@ export default function LoginPage() { const doLogin = async () => { if (!validate()) { toast({ + status: "error", title: "Invalid Input", description: "Please fill in all fields and make sure your email is valid.", - status: "error", - duration: 3000, isClosable: true, }); return; @@ -62,22 +61,35 @@ export default function LoginPage() { try { // authSlice will automatically handle the response - const user = await login(formState).unwrap(); - if (user.code === 0) navigate("/"); + await login(formState).unwrap(); + navigate("/"); } catch (err) { const errTyped = err as { status: number | string; data: Wrap }; toast({ + status: "error", title: "Error", description: errTyped.status === 200 ? errTyped.data.msg : "Oh no, there was an error!", - status: "error", - duration: 3000, isClosable: true, }); } }; + const doSSOLogin = () => { + toast({ + status: "error", + title: "Error", + description: "Not Implemented", + isClosable: true, + }); + }; + const formArea = ( -
+ { + e.preventDefault(); + void doLogin(); + }} + > Email @@ -85,7 +97,7 @@ export default function LoginPage() { {/* eslint-disable-next-line @typescript-eslint/no-misused-promises */} - @@ -101,7 +113,7 @@ export default function LoginPage() { - @@ -111,7 +123,7 @@ export default function LoginPage() { const header = (
- +
Log in to your account @@ -126,7 +138,7 @@ export default function LoginPage() { ); return ( - + {header}