Files
cv4/resources/js/Pages/Auth/Login.jsx
2024-12-27 20:43:18 -05:00

94 lines
4.7 KiB
JavaScript

import InputError from '@/Components/InputError';
import Checkbox from '@/Components/Checkbox';
import PrimaryButton from '@/Components/PrimaryButton';
import TextInput from '@/Components/TextInput';
import { Head, Link, useForm } from '@inertiajs/react';
import { Label } from "@/components/ui/label"
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/Components/ui/card.jsx";
import GuestLayout from "@/Layouts/GuestLayout.jsx";
import { Alert, AlertDescription } from "@/Components/ui/alert.jsx";
export default function Login({ status, canResetPassword }) {
const { data, setData, post, processing, errors, reset } = useForm({
email: '',
password: '',
remember: false,
});
const submit = (e) => {
e.preventDefault();
post(route('login'), {
onFinish: () => reset('password'),
});
};
return (
<GuestLayout>
<Head title="Login" />
<div className="flex flex-col gap-6">
{ status && (<Alert>
<AlertDescription>
{ status }
</AlertDescription>
</Alert> ) }
<Card>
<CardHeader>
<CardTitle className="text-2xl">Login</CardTitle>
<CardDescription>
Enter your email below to login to your account
</CardDescription>
</CardHeader>
<CardContent>
<form onSubmit={ submit }>
<div className="flex flex-col gap-6">
<div className="grid gap-2">
<Label htmlFor="email">E-mail Address</Label>
<TextInput type="email" id="email" placeholder="me@yumj.in" value={ data.email }
onChange={ (e) => setData('email', e.target.value) } required />
<InputError message={ errors.email } className="mt-2" />
</div>
<div className="grid gap-2">
<div className="flex items-center">
<Label htmlFor="password">Password</Label>
<Link href={ route('password.request') }
className="ml-auto inline-block text-sm underline-offset-4 hover:underline">
Forgot your password?
</Link>
</div>
<TextInput id="password" type="password" name="password" value={ data.password }
autoComplete="current-password"
onChange={ (e) => setData('password', e.target.value) } />
<InputError message={ errors.password } className="mt-2" />
</div>
<div className="grid gap-2">
<div className="flex items-center space-x-2">
<Checkbox
id="remember"
name="remember"
checked={ data.remember }
onChange={ (e) =>
setData('remember', e.target.checked)
}
/>
<label htmlFor="remember"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">Remember me</label>
</div>
</div>
<PrimaryButton type="submit" disabled={ processing }
className="w-full">Login</PrimaryButton>
</div>
<div className="mt-4 text-center text-sm">
Don&apos;t have an account?&nbsp;
<Link href={ route('register') } className="underline underline-offset-4">
Sign up
</Link>
</div>
</form>
</CardContent>
</Card>
</div>
</GuestLayout>
);
}