full user login flow, redirect user from root path to dashboard

This commit is contained in:
IluaAir
2025-10-21 22:40:37 +03:00
parent 17b64121db
commit 246cd54a47
4 changed files with 58 additions and 3 deletions

View File

@@ -12,10 +12,11 @@ import {
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { login } from "@/api/auth.service"
import { Link } from "react-router"
import { Link, useNavigate } from "react-router"
export function LoginPage({ className }) {
const navigate = useNavigate()
const [username, setUsername] = useState("")
const [password, setPassword] = useState("")
const [isLoading, setIsLoading] = useState(false)
@@ -33,6 +34,9 @@ export function LoginPage({ className }) {
setSuccess("Login successful!")
console.log("Logged in:", result)
// Redirect to dashboard after successful login
navigate('/dashboard', { replace: true })
} catch (err) {
setError(err.detail || "Login failed. Please check your credentials.")
console.error("Login error:", err)