From 2c1fb161d1a5ffff119c6292b876cb08814f8e79 Mon Sep 17 00:00:00 2001 From: Ryjek Date: Sun, 12 Jul 2026 22:08:11 +0200 Subject: [PATCH] add login view --- src/views/LoginView.jsx | 70 +++++++++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 17 deletions(-) diff --git a/src/views/LoginView.jsx b/src/views/LoginView.jsx index 4d8e54e..9684004 100644 --- a/src/views/LoginView.jsx +++ b/src/views/LoginView.jsx @@ -1,4 +1,4 @@ -import {Button, TextField} from "@mui/material"; +import {Box, Button, CircularProgress, Paper, Stack, TextField, Typography} from "@mui/material"; import {useNavigate} from "react-router-dom"; import {useAuthStore} from "../stores/authStore.jsx"; import {useState} from "react"; @@ -8,33 +8,69 @@ export default function LoginView() { const loginAction = useAuthStore(s => s.login); const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); + const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(null) async function handleLogin(e) { e.preventDefault(); + setIsLoading(true); try{ await loginAction(username, password); navigate("/"); } catch (e) { setError(e); + } finally { + setIsLoading(false); } } + + //
+ // {error &&

{error}

} + //
return ( -
- {error &&

{error}

} -
- setUsername(e.target.value)} - value={username} - /> -
-
- setPassword(e.target.value)} - value={password} - /> -
- -
+ + + + Logowanie + setUsername(e.target.value)} + value={username} + fullWidth + disabled={isLoading} + /> + setPassword(e.target.value)} + value={password} + fullWidth + disabled={isLoading} + /> + {isLoading ? ( + + + + ) : ( + + )} + + + + ); } \ No newline at end of file