import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { useAuth } from '@/hooks/useAuth'; import { useToast } from '@/hooks/use-toast'; export const LoginForm = () => { const [isLoading, setIsLoading] = useState(false); const { login, register } = useAuth(); const { toast } = useToast(); const handleLogin = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); const formData = new FormData(e.currentTarget); const email = formData.get('email') as string; const password = formData.get('password') as string; try { await login(email, password); toast({ title: "Login effettuato", description: "Benvenuto nell'inventario Hackinpovo!", }); } catch (error) { toast({ title: "Errore di login", description: "Controlla le tue credenziali.", variant: "destructive", }); } finally { setIsLoading(false); } }; const handleRegister = async (e: React.FormEvent) => { e.preventDefault(); setIsLoading(true); const formData = new FormData(e.currentTarget); const email = formData.get('email') as string; const password = formData.get('password') as string; const name = formData.get('name') as string; try { await register(email, password, name); toast({ title: "Account creato", description: "Benvenuto nell'inventario Hackinpovo!", }); } catch (error) { toast({ title: "Errore di registrazione", description: "Si รจ verificato un errore durante la registrazione.", variant: "destructive", }); } finally { setIsLoading(false); } }; return (
HS
Inventario Hackinpovo Gestisci l'inventario di Hackinpovo
Login Registrati
); };