TIFNJK_E41222887/resources/js/pages/auth/login.tsx

142 lines
6.4 KiB
TypeScript

import { Head, useForm } from '@inertiajs/react';
import React from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent, CardHeader } from '@/components/ui/card';
import { Checkbox } from '@/components/ui/checkbox';
import { Input } from '@/components/ui/input';
import { Label } from '@/components/ui/label';
// ─── Types ───────────────────────────────────────────────────────────────────
type Props = {
status?: string;
canResetPassword: boolean;
};
// ─── Component ───────────────────────────────────────────────────────────────
export default function Login({ status, canResetPassword }: Props) {
const { data, setData, post, processing, errors } = useForm({
email: '',
password: '',
remember: false as boolean,
});
const submit = (e: React.FormEvent) => {
e.preventDefault();
post('/login');
};
return (
// Layar penuh, tengah, background abu muda
<div className="min-h-screen bg-zinc-50 flex items-center justify-center px-4">
<Head title="Login — HRIS" />
<div className="w-full max-w-sm">
{/* Logo / Nama Aplikasi */}
<div className="mb-8 text-center">
<div className="mx-auto mb-4 flex h-16 w-16 items-center justify-center">
<img src={"/assets/logo.jpg"} alt="Logo" className="h-full w-full object-contain p-1" />
</div>
<h1 className="text-2xl font-bold tracking-tight text-foreground">HRIS APP</h1>
<p className="mt-1 text-sm text-muted-foreground">PT. ZHANHUI JAYA INDONESIA</p>
</div>
{/* Card Login */}
<Card className="border shadow-sm">
<CardHeader className="pb-0 pt-6 px-6">
{/* Status (misal: password reset berhasil) */}
{status && (
<div className="mb-2 rounded-md bg-green-50 px-4 py-3 text-sm font-medium text-green-700">
{status}
</div>
)}
</CardHeader>
<CardContent className="px-6 pb-6 pt-4">
<form onSubmit={submit} className="space-y-4">
{/* Email */}
<div className="space-y-2">
<Label htmlFor="email">Email</Label>
<Input
id="email"
type="email"
placeholder="nama@perusahaan.com"
autoFocus
autoComplete="email"
value={data.email}
onChange={(e) => setData('email', e.target.value)}
/>
{errors.email && (
<p className="text-xs text-red-500">{errors.email}</p>
)}
</div>
{/* Password */}
<div className="space-y-2">
<div className="flex items-center justify-between">
<Label htmlFor="password">Password</Label>
{canResetPassword && (
<a
href="/forgot-password"
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
>
Lupa password?
</a>
)}
</div>
<Input
id="password"
type="password"
placeholder="••••••••"
autoComplete="current-password"
value={data.password}
onChange={(e) => setData('password', e.target.value)}
/>
{errors.password && (
<p className="text-xs text-red-500">{errors.password}</p>
)}
</div>
{/* Remember Me */}
<div className="flex items-center gap-2">
<Checkbox
id="remember"
checked={data.remember}
onCheckedChange={(checked) =>
setData('remember', checked === true)
}
/>
<Label
htmlFor="remember"
className="text-sm font-normal text-muted-foreground cursor-pointer"
>
Ingat saya
</Label>
</div>
{/* Tombol Login */}
<Button
type="submit"
className="w-full"
disabled={processing}
>
{processing ? 'Memproses...' : 'Masuk'}
</Button>
</form>
</CardContent>
</Card>
{/* Footer */}
<p className="mt-6 text-center text-xs text-muted-foreground">
&copy; {new Date().getFullYear()} HRIS App. All rights reserved.
</p>
</div>
</div>
);
}