"use client"; import { Button } from "@/components/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card" import { Input } from "@/components/ui/input" import { Label } from "@/components/ui/label" import { AlertCircle } from "lucide-react" import { Alert, AlertDescription, AlertTitle, } from "@/components/ui/alert" import { useState, useEffect } from "react"; import Cookies from "js-cookie"; import { useRouter } from "next/navigation"; import axios from "axios"; export default function Home() { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); const router = useRouter(); const [error, setError] = useState(''); const [errorVisible, setErrorVisible] = useState(false); useEffect(() => { const token = Cookies.get('token'); if (token) { router.push('/dashboard'); } }, [router]); interface LoginResponse { token: string; } const login = async () => { try { const response = await axios.post('/api/auth/login', { username, password }); const { token } = response.data as LoginResponse; Cookies.set('token', token); router.push('/dashboard'); } catch (error: any) { setError(error.response.data.error); setErrorVisible(true) } } return (
Login Enter your Login data of the compose.yml file below to access {errorVisible && ( <>
Error {error}
)}
setUsername(e.target.value)} />
setPassword(e.target.value)}/>
) }