Spaces:
Build error
Build error
| import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogDescription, DialogFooter } from '@/components/ui/dialog'; | |
| import { Button } from '@/components/ui/button'; | |
| import { Input } from '@/components/ui/input'; | |
| import { Label } from '@/components/ui/label'; | |
| import { useAuth } from '@/context/AuthContext'; | |
| import { useState } from 'react'; | |
| export default function AuthModal({ open, onOpenChange }) { | |
| const { login } = useAuth(); | |
| const [email, setEmail] = useState(''); | |
| const [password, setPassword] = useState(''); | |
| const [isLoading, setIsLoading] = useState(false); | |
| const handleSubmit = async (e) => { | |
| e.preventDefault(); | |
| setIsLoading(true); | |
| await login(email, password); | |
| setIsLoading(false); | |
| onOpenChange(false); | |
| }; | |
| return ( | |
| <Dialog open={open} onOpenChange={onOpenChange}> | |
| <DialogContent className="sm:max-w-[425px]"> | |
| <DialogHeader> | |
| <DialogTitle>Welcome back</DialogTitle> | |
| <DialogDescription> | |
| Enter your credentials to access your AI studio workspace. | |
| </DialogDescription> | |
| </DialogHeader> | |
| <form onSubmit={handleSubmit} className="grid gap-4 py-4"> | |
| <div className="grid gap-2"> | |
| <Label htmlFor="email">Email</Label> | |
| <Input | |
| id="email" | |
| type="email" | |
| placeholder="m@example.com" | |
| value={email} | |
| onChange={(e) => setEmail(e.target.value)} | |
| required | |
| /> | |
| </div> | |
| <div className="grid gap-2"> | |
| <Label htmlFor="password">Password</Label> | |
| <Input | |
| id="password" | |
| type="password" | |
| value={password} | |
| onChange={(e) => setPassword(e.target.value)} | |
| required | |
| /> | |
| </div> | |
| <DialogFooter> | |
| <Button type="submit" disabled={isLoading} className="w-full"> | |
| {isLoading ? 'Signing in...' : 'Sign In'} | |
| </Button> | |
| </DialogFooter> | |
| </form> | |
| <div className="text-center text-xs text-muted-foreground"> | |
| Don't have an account? <a href="#" className="text-primary hover:underline">Register</a> | |
| </div> | |
| </DialogContent> | |
| </Dialog> | |
| ); | |
| } |