126 lines
4.2 KiB
TypeScript
126 lines
4.2 KiB
TypeScript
/**
|
|
* File: page.tsx
|
|
* Created by: AI Assistant
|
|
* Date: 2025-11-29
|
|
* Purpose: Sign in page for kreatiVortex platform
|
|
* Part of: kreatiVortex - Platform Pembelajaran Tari Online
|
|
*/
|
|
|
|
'use client';
|
|
|
|
import { useState } from 'react';
|
|
import { Link, useRouter } from '@/i18n/routing';
|
|
import { authClient } from '@/lib/auth-client';
|
|
import { useTranslations } from 'next-intl';
|
|
import { Input } from "@/components/ui/input";
|
|
import { Label } from "@/components/ui/label";
|
|
|
|
export default function SignIn() {
|
|
const t = useTranslations('Auth');
|
|
const [email, setEmail] = useState('');
|
|
const [password, setPassword] = useState('');
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
const router = useRouter();
|
|
|
|
const handleSubmit = async (e: React.FormEvent) => {
|
|
e.preventDefault();
|
|
setIsLoading(true);
|
|
|
|
await authClient.signIn.email({
|
|
email,
|
|
password,
|
|
}, {
|
|
onSuccess: () => {
|
|
router.push('/dashboard');
|
|
},
|
|
onError: (ctx) => {
|
|
alert(ctx.error.message);
|
|
setIsLoading(false);
|
|
}
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div className="min-h-screen flex items-center justify-center px-4">
|
|
<div className="relative z-10 w-full max-w-md">
|
|
<div className="bg-white/10 backdrop-blur-lg rounded-2xl p-8 border border-white/20">
|
|
{/* Logo */}
|
|
<div className="text-center mb-8">
|
|
<h1 className="text-3xl font-bold text-white mb-2">
|
|
kreati<span className="text-gold-400">Vortex</span>
|
|
</h1>
|
|
<p className="text-gray-300">{t('signInTitle')}</p>
|
|
</div>
|
|
|
|
{/* Form */}
|
|
<form onSubmit={handleSubmit} className="space-y-6">
|
|
<div className="grid gap-2">
|
|
<Label htmlFor="email" className="text-gray-300">
|
|
{t('emailLabel')}
|
|
</Label>
|
|
<Input
|
|
id="email"
|
|
type="email"
|
|
value={email}
|
|
onChange={(e) => setEmail(e.target.value)}
|
|
className="bg-white/10 border-white/20 text-white placeholder:text-gray-400 focus-visible:ring-gold-400"
|
|
placeholder="nama@email.com"
|
|
required
|
|
/>
|
|
</div>
|
|
|
|
<div className="grid gap-2">
|
|
<Label htmlFor="password" className="text-gray-300">
|
|
{t('passwordLabel')}
|
|
</Label>
|
|
<Input
|
|
id="password"
|
|
type="password"
|
|
value={password}
|
|
onChange={(e) => setPassword(e.target.value)}
|
|
className="bg-white/10 border-white/20 text-white placeholder:text-gray-400 focus-visible:ring-gold-400"
|
|
placeholder="••••••••"
|
|
required
|
|
/>
|
|
</div>
|
|
|
|
<div className="flex items-center justify-between">
|
|
<div className="flex items-center space-x-2">
|
|
<input
|
|
id="remember"
|
|
type="checkbox"
|
|
className="h-4 w-4 bg-white/10 border-white/20 rounded focus:ring-gold-400"
|
|
/>
|
|
<Label htmlFor="remember" className="text-gray-300 font-normal">
|
|
{t('rememberMe')}
|
|
</Label>
|
|
</div>
|
|
<Link href="/auth/forgot-password" className="text-sm text-gold-400 hover:text-gold-300">
|
|
{t('forgotPassword')}
|
|
</Link>
|
|
</div>
|
|
|
|
<button
|
|
type="submit"
|
|
disabled={isLoading}
|
|
className="w-full py-3 px-4 bg-gold-500 hover:bg-gold-400 text-navy-900 font-semibold rounded-lg transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
|
|
>
|
|
{isLoading ? t('processing') : t('signInButton')}
|
|
</button>
|
|
</form>
|
|
|
|
{/* Sign up link */}
|
|
<div className="mt-8 text-center">
|
|
<p className="text-gray-300">
|
|
{t('noAccount')}{' '}
|
|
<Link href="/auth/signup" className="text-gold-400 hover:text-gold-300 font-medium">
|
|
{t('registerNow')}
|
|
</Link>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|