%PDF- %PDF-
| Direktori : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/ |
| Current File : /home2/rezakur1/muakita.rezakurnia.com/Mua-Kita-Web/src/components/LoginModal.tsx |
import React, { useState } from 'react';
import { Role } from '../types';
import { X, ShieldCheck, Crown, Sparkles, ArrowRight, UserCheck, Lock, Mail, CheckCircle2 } from 'lucide-react';
interface LoginModalProps {
isOpen: boolean;
onClose: () => void;
onLogin: (role: Role) => void;
}
export const LoginModal: React.FC<LoginModalProps> = ({ isOpen, onClose, onLogin }) => {
const [selectedRole, setSelectedRole] = useState<Role>('owner');
const [email, setEmail] = useState('owner@rezaameliamua.com');
const [password, setPassword] = useState('••••••••');
if (!isOpen) return null;
const handleRoleSelect = (role: Role) => {
setSelectedRole(role);
if (role === 'superadmin') {
setEmail('admin@muakita.com');
} else {
setEmail('owner@rezaameliamua.com');
}
};
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
onLogin(selectedRole);
};
return (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/60 backdrop-blur-xs p-4 animate-in fade-in duration-200">
<div
className="bg-white rounded-3xl max-w-md w-full p-6 sm:p-7 shadow-2xl border border-slate-100 relative space-y-6 animate-in zoom-in-95 duration-200"
onClick={(e) => e.stopPropagation()}
>
{/* Close Button */}
<button
onClick={onClose}
className="absolute top-5 right-5 w-8 h-8 rounded-full bg-slate-100 hover:bg-slate-200 text-slate-500 flex items-center justify-center transition-colors cursor-pointer"
>
<X className="w-4 h-4" />
</button>
{/* Modal Header */}
<div className="text-center space-y-2">
<div className="inline-flex items-center gap-2 px-3 py-1 rounded-full bg-pink-50 border border-pink-100 text-[#EC167F] text-xs font-black">
<Sparkles className="w-3.5 h-3.5" />
<span>MuaKita Platform Login</span>
</div>
<h2 className="text-2xl font-black text-slate-900 tracking-tight">Masuk ke Dashboard</h2>
<p className="text-xs text-slate-500 font-medium">
Pilih role akun dummy di bawah ini untuk mengakses sistem MuaKita
</p>
</div>
{/* Preset Role Selector Cards */}
<div className="space-y-2.5">
<label className="text-xs font-bold text-slate-700 block">Pilih Mode Akses (Demo):</label>
<div className="grid grid-cols-1 gap-2.5">
{/* Bisnis Owner Option */}
<button
type="button"
onClick={() => handleRoleSelect('owner')}
className={`p-3.5 rounded-2xl border text-left transition-all cursor-pointer flex items-start gap-3 relative ${
selectedRole === 'owner'
? 'bg-pink-50/80 border-[#EC167F] ring-2 ring-[#EC167F]/20 shadow-xs'
: 'bg-slate-50 hover:bg-slate-100 border-slate-200/80 text-slate-700'
}`}
>
<div className={`w-10 h-10 rounded-xl flex items-center justify-center shrink-0 ${
selectedRole === 'owner' ? 'bg-[#EC167F] text-white shadow-xs' : 'bg-slate-200 text-slate-600'
}`}>
<UserCheck className="w-5 h-5" />
</div>
<div className="flex-1 min-w-0 pr-6">
<div className="flex items-center gap-1.5">
<h3 className="text-xs font-extrabold text-slate-900">Bisnis Owner / Studio MUA</h3>
<span className="px-1.5 py-0.5 rounded bg-pink-100 text-[#EC167F] font-black text-[9px]">UTAMA</span>
</div>
<p className="text-[11px] text-slate-500 mt-0.5 font-medium leading-relaxed">
Kelola booking, jadwal, invoice, CRM pelanggan, dan keuangan studio MUA Anda.
</p>
</div>
{selectedRole === 'owner' && (
<CheckCircle2 className="w-5 h-5 text-[#EC167F] absolute top-3.5 right-3.5" />
)}
</button>
{/* Super Admin Option */}
<button
type="button"
onClick={() => handleRoleSelect('superadmin')}
className={`p-3.5 rounded-2xl border text-left transition-all cursor-pointer flex items-start gap-3 relative ${
selectedRole === 'superadmin'
? 'bg-purple-50/80 border-purple-600 ring-2 ring-purple-600/20 shadow-xs'
: 'bg-slate-50 hover:bg-slate-100 border-slate-200/80 text-slate-700'
}`}
>
<div className={`w-10 h-10 rounded-xl flex items-center justify-center shrink-0 ${
selectedRole === 'superadmin' ? 'bg-purple-600 text-white shadow-xs' : 'bg-slate-200 text-slate-600'
}`}>
<Crown className="w-5 h-5" />
</div>
<div className="flex-1 min-w-0 pr-6">
<div className="flex items-center gap-1.5">
<h3 className="text-xs font-extrabold text-slate-900">Super Admin Platform</h3>
<span className="px-1.5 py-0.5 rounded bg-purple-100 text-purple-700 font-black text-[9px]">SAAS ADMIN</span>
</div>
<p className="text-[11px] text-slate-500 mt-0.5 font-medium leading-relaxed">
Kelola daftar tenant studio, paket berlangganan, omset platform, & sistem.
</p>
</div>
{selectedRole === 'superadmin' && (
<CheckCircle2 className="w-5 h-5 text-purple-600 absolute top-3.5 right-3.5" />
)}
</button>
</div>
</div>
{/* Dummy Inputs */}
<form onSubmit={handleSubmit} className="space-y-3 pt-1">
<div>
<label className="block text-xs font-bold text-slate-700 mb-1">Email</label>
<div className="relative">
<Mail className="w-4 h-4 text-slate-400 absolute left-3.5 top-3" />
<input
type="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
className="w-full pl-10 pr-3.5 py-2.5 bg-slate-50 border border-slate-200 rounded-xl text-xs font-medium focus:bg-white focus:outline-none focus:ring-2 focus:ring-pink-500/20"
required
/>
</div>
</div>
<div>
<label className="block text-xs font-bold text-slate-700 mb-1">Password</label>
<div className="relative">
<Lock className="w-4 h-4 text-slate-400 absolute left-3.5 top-3" />
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
className="w-full pl-10 pr-3.5 py-2.5 bg-slate-50 border border-slate-200 rounded-xl text-xs font-medium focus:bg-white focus:outline-none focus:ring-2 focus:ring-pink-500/20"
required
/>
</div>
</div>
<div className="flex items-center justify-between text-xs pt-1">
<label className="flex items-center gap-2 cursor-pointer font-medium text-slate-600">
<input type="checkbox" defaultChecked className="accent-[#EC167F] w-4 h-4 rounded" />
<span>Ingat Sesi Saya</span>
</label>
<span className="text-[#EC167F] font-bold hover:underline cursor-pointer">Lupa Password?</span>
</div>
{/* Submit Button */}
<button
type="submit"
className="w-full py-3 px-4 bg-[#EC167F] hover:bg-[#D41270] text-white rounded-xl text-xs font-extrabold shadow-md hover:shadow-lg transition-all flex items-center justify-center gap-2 cursor-pointer mt-4"
>
<ShieldCheck className="w-4 h-4" />
<span>Masuk ke Dashboard ({selectedRole === 'superadmin' ? 'Super Admin' : 'Bisnis Owner'})</span>
<ArrowRight className="w-4 h-4" />
</button>
</form>
{/* Footer Note */}
<div className="bg-slate-50 p-3 rounded-xl border border-slate-200/80 text-[11px] text-slate-500 text-center font-medium">
🔒 Bebas akses instan tanpa verifikasi password tambahan untuk kemudahan pengujian.
</div>
</div>
</div>
);
};