Fix register pages: both have 2 steps with ID upload, OTP as modal overlay
All checks were successful
Build frontend / build (push) Successful in 40s
All checks were successful
Build frontend / build (push) Successful in 40s
This commit is contained in:
@ -17,7 +17,8 @@ import { OwnerType, OwnerTypeLabels } from '../../enums';
|
|||||||
|
|
||||||
export default function OwnerRegisterPage() {
|
export default function OwnerRegisterPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [step, setStep] = useState(1); // 1=form, 2=id images, 3=OTP
|
const [step, setStep] = useState(1); // 1=form, 2=id images
|
||||||
|
const [showOtpModal, setShowOtpModal] = useState(false);
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@ -134,7 +135,6 @@ export default function OwnerRegisterPage() {
|
|||||||
console.log('[OwnerRegister] addOwner response:', res);
|
console.log('[OwnerRegister] addOwner response:', res);
|
||||||
|
|
||||||
if (res.status === 200 || res.ok) {
|
if (res.status === 200 || res.ok) {
|
||||||
// ── Store temp token for OTP flow ──
|
|
||||||
const tempToken = res.data;
|
const tempToken = res.data;
|
||||||
if (tempToken) {
|
if (tempToken) {
|
||||||
AuthService.addToken(tempToken);
|
AuthService.addToken(tempToken);
|
||||||
@ -142,36 +142,26 @@ export default function OwnerRegisterPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const apiMessage = res.message || res.data?.message;
|
const apiMessage = res.message || res.data?.message;
|
||||||
toast.success(apiMessage || 'تم إنشاء الحساب! يرجى التحقق من بريدك الإلكتروني', {
|
toast.success(apiMessage || 'تم إنشاء الحساب! يرجى التحقق من بريدك الإلكتروني', { duration: 4000 });
|
||||||
duration: 4000,
|
|
||||||
});
|
|
||||||
|
|
||||||
// ── Auto-login to trigger OTP ──
|
// Auto-login to trigger OTP
|
||||||
console.log('[OwnerRegister] Auto-login to send OTP...');
|
console.log('[OwnerRegister] Auto-login to send OTP...');
|
||||||
const loginRes = await loginWithEmail(formData.email, formData.password);
|
const loginRes = await loginWithEmail(formData.email, formData.password);
|
||||||
console.log('[OwnerRegister] login response:', loginRes);
|
console.log('[OwnerRegister] login response:', loginRes);
|
||||||
|
|
||||||
if (loginRes.status === 206) {
|
if (loginRes.status === 206) {
|
||||||
// OTP sent — move to OTP step
|
|
||||||
const otpToken = loginRes.data;
|
const otpToken = loginRes.data;
|
||||||
if (otpToken) {
|
if (otpToken) AuthService.addToken(otpToken);
|
||||||
AuthService.addToken(otpToken);
|
|
||||||
console.log('[OwnerRegister] OTP token stored');
|
|
||||||
}
|
|
||||||
const loginMsg = loginRes.message || loginRes.data?.message;
|
const loginMsg = loginRes.message || loginRes.data?.message;
|
||||||
toast(loginMsg || 'تم إرسال رمز التحقق إلى بريدك الإلكتروني', { icon: '📧' });
|
toast(loginMsg || 'تم إرسال رمز التحقق إلى بريدك الإلكتروني', { icon: '📧' });
|
||||||
setStep(3);
|
setShowOtpModal(true);
|
||||||
} else if (loginRes.status === 200) {
|
} else if (loginRes.status === 200) {
|
||||||
// Direct login success (no OTP needed)
|
|
||||||
const loginToken = loginRes.data;
|
const loginToken = loginRes.data;
|
||||||
if (loginToken) {
|
if (loginToken) AuthService.addToken(loginToken);
|
||||||
AuthService.addToken(loginToken);
|
|
||||||
}
|
|
||||||
toast.success(loginRes.message || 'تم تسجيل الدخول بنجاح!');
|
toast.success(loginRes.message || 'تم تسجيل الدخول بنجاح!');
|
||||||
router.push('/');
|
router.push('/');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Registration failed
|
|
||||||
const errMsg = res.message || res.data?.message || 'فشل في إنشاء الحساب';
|
const errMsg = res.message || res.data?.message || 'فشل في إنشاء الحساب';
|
||||||
console.error('[OwnerRegister] Registration failed:', errMsg);
|
console.error('[OwnerRegister] Registration failed:', errMsg);
|
||||||
toast.error(errMsg);
|
toast.error(errMsg);
|
||||||
@ -199,17 +189,11 @@ export default function OwnerRegisterPage() {
|
|||||||
console.log('[OwnerRegister] VerifyEmail response:', res);
|
console.log('[OwnerRegister] VerifyEmail response:', res);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
// ── Verified! Remove temp token, redirect to login ──
|
|
||||||
AuthService.deleteToken();
|
AuthService.deleteToken();
|
||||||
console.log('[OwnerRegister] Temp token removed after verification');
|
console.log('[OwnerRegister] Temp token removed after verification');
|
||||||
|
toast.success(res.message || 'تم التحقق من البريد الإلكتروني بنجاح!', { duration: 3000 });
|
||||||
toast.success(res.message || 'تم التحقق من البريد الإلكتروني بنجاح!', {
|
setShowOtpModal(false);
|
||||||
duration: 3000,
|
setTimeout(() => router.push('/login'), 1500);
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
router.push('/login');
|
|
||||||
}, 1500);
|
|
||||||
} else {
|
} else {
|
||||||
const errMsg = res.message || res.data?.message || 'رمز التحقق غير صحيح';
|
const errMsg = res.message || res.data?.message || 'رمز التحقق غير صحيح';
|
||||||
console.error('[OwnerRegister] Verification failed:', errMsg);
|
console.error('[OwnerRegister] Verification failed:', errMsg);
|
||||||
@ -223,11 +207,9 @@ export default function OwnerRegisterPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ─── Resend OTP ───
|
|
||||||
const handleResendOTP = async () => {
|
const handleResendOTP = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
console.log('[OwnerRegister] Resending email OTP...');
|
console.log('[OwnerRegister] Resending email OTP...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendEmailOTP();
|
await sendEmailOTP();
|
||||||
toast.success('تم إرسال رمز تحقق جديد');
|
toast.success('تم إرسال رمز تحقق جديد');
|
||||||
@ -253,82 +235,58 @@ export default function OwnerRegisterPage() {
|
|||||||
<div className="min-h-screen bg-gradient-to-br from-gray-950 via-gray-900 to-gray-950 flex items-center justify-center p-4 relative overflow-hidden">
|
<div className="min-h-screen bg-gradient-to-br from-gray-950 via-gray-900 to-gray-950 flex items-center justify-center p-4 relative overflow-hidden">
|
||||||
<Toaster position="top-center" reverseOrder={false} />
|
<Toaster position="top-center" reverseOrder={false} />
|
||||||
|
|
||||||
{/* Background blobs */}
|
|
||||||
<div className="absolute inset-0 overflow-hidden">
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
{[...Array(20)].map((_, i) => (
|
{[...Array(20)].map((_, i) => (
|
||||||
<motion.div
|
<motion.div key={i} className="absolute rounded-full bg-amber-500/10"
|
||||||
key={i}
|
style={{ left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`, width: Math.random() * 200 + 50, height: Math.random() * 200 + 50 }}
|
||||||
className="absolute rounded-full bg-amber-500/10"
|
|
||||||
style={{
|
|
||||||
left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`,
|
|
||||||
width: Math.random() * 200 + 50, height: Math.random() * 200 + 50,
|
|
||||||
}}
|
|
||||||
animate={{ x: [0, Math.random() * 100 - 50, 0], y: [0, Math.random() * 100 - 50, 0] }}
|
animate={{ x: [0, Math.random() * 100 - 50, 0], y: [0, Math.random() * 100 - 50, 0] }}
|
||||||
transition={{ duration: Math.random() * 15 + 15, repeat: Infinity, ease: "linear" }}
|
transition={{ duration: Math.random() * 15 + 15, repeat: Infinity, ease: "linear" }} />
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<motion.div
|
<motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.5 }}
|
||||||
initial={{ opacity: 0, scale: 0.95 }}
|
className="relative z-10 w-full max-w-2xl">
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
{/* Progress */}
|
||||||
transition={{ duration: 0.5 }}
|
|
||||||
className="relative z-10 w-full max-w-2xl"
|
|
||||||
>
|
|
||||||
{/* Progress bar */}
|
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<div className="flex items-center justify-between mb-4">
|
<div className="flex items-center justify-between mb-4">
|
||||||
<Link href="/auth/choose-role" className="flex items-center gap-2 text-gray-400 hover:text-white transition-colors group">
|
<Link href="/auth/choose-role" className="flex items-center gap-2 text-gray-400 hover:text-white transition-colors group">
|
||||||
<motion.div whileHover={{ x: -5 }}><ArrowLeft className="w-4 h-4" /></motion.div>
|
<motion.div whileHover={{ x: -5 }}><ArrowLeft className="w-4 h-4" /></motion.div>
|
||||||
<span>العودة</span>
|
<span>العودة</span>
|
||||||
</Link>
|
</Link>
|
||||||
<span className="text-sm text-gray-400">خطوة {step} من 3</span>
|
<span className="text-sm text-gray-400">خطوة {step} من 2</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex gap-2">
|
<div className="flex gap-2">
|
||||||
{[1, 2, 3].map((s) => (
|
{[1, 2].map((s) => (
|
||||||
<motion.div key={s} className={`h-2 flex-1 rounded-full ${step >= s ? 'bg-amber-500' : 'bg-gray-700'}`} animate={{ scaleX: step >= s ? 1 : 0.5 }} />
|
<motion.div key={s} className={`h-2 flex-1 rounded-full ${step >= s ? 'bg-amber-500' : 'bg-gray-700'}`} animate={{ scaleX: step >= s ? 1 : 0.5 }} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<motion.div
|
<motion.div key={step} initial={{ opacity: 0, x: 20 }} animate={{ opacity: 1, x: 0 }} exit={{ opacity: 0, x: -20 }} transition={{ duration: 0.3 }}
|
||||||
key={step}
|
className="bg-white/5 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/10 overflow-hidden">
|
||||||
initial={{ opacity: 0, x: 20 }}
|
|
||||||
animate={{ opacity: 1, x: 0 }}
|
|
||||||
exit={{ opacity: 0, x: -20 }}
|
|
||||||
transition={{ duration: 0.3 }}
|
|
||||||
className="bg-white/5 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/10 overflow-hidden"
|
|
||||||
>
|
|
||||||
{/* Header */}
|
|
||||||
<div className="bg-gradient-to-r from-amber-500 to-amber-600 p-8 text-center relative overflow-hidden">
|
<div className="bg-gradient-to-r from-amber-500 to-amber-600 p-8 text-center relative overflow-hidden">
|
||||||
<motion.div initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ delay: 0.2, type: "spring" }}
|
<motion.div initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ delay: 0.2, type: "spring" }}
|
||||||
className="absolute -top-10 -right-10 w-40 h-40 bg-white/10 rounded-full" />
|
className="absolute -top-10 -right-10 w-40 h-40 bg-white/10 rounded-full" />
|
||||||
<motion.div initial={{ y: 20, opacity: 0 }} animate={{ y: 0, opacity: 1 }} className="relative z-10">
|
<motion.div initial={{ y: 20, opacity: 0 }} animate={{ y: 0, opacity: 1 }} className="relative z-10">
|
||||||
<motion.div
|
<motion.div animate={{ rotate: [0, 10, -10, 0] }} transition={{ duration: 2, repeat: Infinity }}
|
||||||
animate={{ rotate: [0, 10, -10, 0] }}
|
className="w-20 h-20 mx-auto mb-4 bg-white/20 rounded-2xl flex items-center justify-center backdrop-blur-sm">
|
||||||
transition={{ duration: 2, repeat: Infinity }}
|
<Building className="w-10 h-10 text-white" />
|
||||||
className="w-20 h-20 mx-auto mb-4 bg-white/20 rounded-2xl flex items-center justify-center backdrop-blur-sm"
|
|
||||||
>
|
|
||||||
{step === 3 ? <KeyRound className="w-10 h-10 text-white" /> : <Building className="w-10 h-10 text-white" />}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<h1 className="text-3xl font-bold text-white mb-2">
|
<h1 className="text-3xl font-bold text-white mb-2">
|
||||||
{step === 1 ? 'معلومات المالك' : step === 2 ? 'الوثائق الرسمية' : 'التحقق من البريد'}
|
{step === 1 ? 'معلومات المالك' : 'الوثائق الرسمية'}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-amber-100">
|
<p className="text-amber-100">
|
||||||
{step === 1 ? 'أدخل معلوماتك الأساسية' : step === 2 ? 'يرجى رفع صور الهوية للتحقق' : 'أدخل رمز التحقق المرسل إلى بريدك'}
|
{step === 1 ? 'أدخل معلوماتك الأساسية' : 'يرجى رفع صور الهوية للتحقق'}
|
||||||
</p>
|
</p>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="p-8">
|
<div className="p-8">
|
||||||
<motion.form
|
<motion.form variants={staggerContainer} initial="initial" animate="animate"
|
||||||
variants={staggerContainer}
|
onSubmit={step === 1 ? (e) => { e.preventDefault(); handleNextStep(); } : handleSubmit}
|
||||||
initial="initial"
|
className="space-y-6">
|
||||||
animate="animate"
|
|
||||||
onSubmit={step === 1 ? handleNextStep : step === 2 ? handleSubmit : (e) => { e.preventDefault(); handleVerifyOTP(); }}
|
{/* ─── STEP 1: Form ─── */}
|
||||||
className="space-y-6"
|
|
||||||
>
|
|
||||||
{/* ─── STEP 1: Form fields ─── */}
|
|
||||||
{step === 1 && (
|
{step === 1 && (
|
||||||
<>
|
<>
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
@ -387,20 +345,15 @@ export default function OwnerRegisterPage() {
|
|||||||
{errors.whatsapp && <p className="text-red-500 text-sm mt-1">{errors.whatsapp}</p>}
|
{errors.whatsapp && <p className="text-red-500 text-sm mt-1">{errors.whatsapp}</p>}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{/* Owner Type */}
|
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
<label className="block text-sm font-medium text-gray-300 mb-2">نوع المالك <span className="text-red-500">*</span></label>
|
<label className="block text-sm font-medium text-gray-300 mb-2">نوع المالك <span className="text-red-500">*</span></label>
|
||||||
<select
|
<select value={formData.ownerType}
|
||||||
value={formData.ownerType}
|
|
||||||
onChange={(e) => setFormData({...formData, ownerType: e.target.value})}
|
onChange={(e) => setFormData({...formData, ownerType: e.target.value})}
|
||||||
className="w-full py-3 px-4 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white appearance-none cursor-pointer"
|
className="w-full py-3 px-4 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white appearance-none cursor-pointer">
|
||||||
>
|
|
||||||
{Object.entries(OwnerTypeLabels).map(([value, label]) => (
|
{Object.entries(OwnerTypeLabels).map(([value, label]) => (
|
||||||
<option key={value} value={value} className="bg-gray-900 text-white">{label}</option>
|
<option key={value} value={value} className="bg-gray-900 text-white">{label}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<p className="text-xs text-gray-500 mt-1">المحدد: {OwnerTypeLabels[formData.ownerType]}</p>
|
|
||||||
<p className="text-xs text-gray-600">[Console] ownerType = {formData.ownerType}</p>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
@ -414,7 +367,7 @@ export default function OwnerRegisterPage() {
|
|||||||
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.password ? 'border-red-500' : 'border-gray-700'}`}
|
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.password ? 'border-red-500' : 'border-gray-700'}`}
|
||||||
placeholder="أدخل كلمة المرور" />
|
placeholder="أدخل كلمة المرور" />
|
||||||
<button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
<button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
||||||
{showPassword ? <EyeOff className="w-5 h-5 text-gray-400 hover:text-gray-300" /> : <Eye className="w-5 h-5 text-gray-400 hover:text-gray-300" />}
|
{showPassword ? <EyeOff className="w-5 h-5 text-gray-400" /> : <Eye className="w-5 h-5 text-gray-400" />}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{errors.password && <p className="text-red-500 text-sm mt-1">{errors.password}</p>}
|
{errors.password && <p className="text-red-500 text-sm mt-1">{errors.password}</p>}
|
||||||
@ -431,7 +384,7 @@ export default function OwnerRegisterPage() {
|
|||||||
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.confirmPassword ? 'border-red-500' : 'border-gray-700'}`}
|
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.confirmPassword ? 'border-red-500' : 'border-gray-700'}`}
|
||||||
placeholder="أعد إدخال كلمة المرور" />
|
placeholder="أعد إدخال كلمة المرور" />
|
||||||
<button type="button" onClick={() => setShowConfirmPassword(!showConfirmPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
<button type="button" onClick={() => setShowConfirmPassword(!showConfirmPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
||||||
{showConfirmPassword ? <EyeOff className="w-5 h-5 text-gray-400 hover:text-gray-300" /> : <Eye className="w-5 h-5 text-gray-400 hover:text-gray-300" />}
|
{showConfirmPassword ? <EyeOff className="w-5 h-5 text-gray-400" /> : <Eye className="w-5 h-5 text-gray-400" />}
|
||||||
</button>
|
</button>
|
||||||
{formData.confirmPassword && (
|
{formData.confirmPassword && (
|
||||||
<div className="absolute inset-y-0 left-12 flex items-center">
|
<div className="absolute inset-y-0 left-12 flex items-center">
|
||||||
@ -460,13 +413,7 @@ export default function OwnerRegisterPage() {
|
|||||||
<X className="w-4 h-4 text-white" />
|
<X className="w-4 h-4 text-white" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (<><Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" /><p className="text-gray-400">اضغط لرفع الصورة</p><p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p></>)}
|
||||||
<>
|
|
||||||
<Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" />
|
|
||||||
<p className="text-gray-400">اضغط لرفع الصورة</p>
|
|
||||||
<p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{errors.front && <p className="text-red-500 text-sm mt-1">{errors.front}</p>}
|
{errors.front && <p className="text-red-500 text-sm mt-1">{errors.front}</p>}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@ -484,13 +431,7 @@ export default function OwnerRegisterPage() {
|
|||||||
<X className="w-4 h-4 text-white" />
|
<X className="w-4 h-4 text-white" />
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (<><Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" /><p className="text-gray-400">اضغط لرفع الصورة</p><p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p></>)}
|
||||||
<>
|
|
||||||
<Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" />
|
|
||||||
<p className="text-gray-400">اضغط لرفع الصورة</p>
|
|
||||||
<p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
{errors.back && <p className="text-red-500 text-sm mt-1">{errors.back}</p>}
|
{errors.back && <p className="text-red-500 text-sm mt-1">{errors.back}</p>}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
@ -498,7 +439,7 @@ export default function OwnerRegisterPage() {
|
|||||||
<motion.div variants={fadeInUp} className="flex items-center gap-2">
|
<motion.div variants={fadeInUp} className="flex items-center gap-2">
|
||||||
<input type="checkbox" id="terms" checked={formData.agreeTerms}
|
<input type="checkbox" id="terms" checked={formData.agreeTerms}
|
||||||
onChange={(e) => setFormData({...formData, agreeTerms: e.target.checked})}
|
onChange={(e) => setFormData({...formData, agreeTerms: e.target.checked})}
|
||||||
className="w-4 h-4 rounded border-gray-600 bg-white/5 text-amber-500 focus:ring-amber-500 focus:ring-offset-0" required />
|
className="w-4 h-4 rounded border-gray-600 bg-white/5 text-amber-500 focus:ring-amber-500" required />
|
||||||
<label htmlFor="terms" className="text-sm text-gray-300">
|
<label htmlFor="terms" className="text-sm text-gray-300">
|
||||||
أوافق على <Link href="/terms" className="text-amber-400 hover:text-amber-300">شروط الاستخدام</Link> و <Link href="/privacy" className="text-amber-400 hover:text-amber-300">سياسة الخصوصية</Link>
|
أوافق على <Link href="/terms" className="text-amber-400 hover:text-amber-300">شروط الاستخدام</Link> و <Link href="/privacy" className="text-amber-400 hover:text-amber-300">سياسة الخصوصية</Link>
|
||||||
</label>
|
</label>
|
||||||
@ -506,74 +447,75 @@ export default function OwnerRegisterPage() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ─── STEP 3: OTP ─── */}
|
{/* ─── Buttons ─── */}
|
||||||
{step === 3 && (
|
|
||||||
<motion.div variants={fadeInUp} className="space-y-6">
|
|
||||||
<div className="bg-amber-500/10 border border-amber-500/20 rounded-xl p-4 text-center">
|
|
||||||
<Shield className="w-10 h-10 text-amber-500 mx-auto mb-2" />
|
|
||||||
<p className="text-gray-300 text-sm">تم إرسال رمز التحقق إلى</p>
|
|
||||||
<p className="text-amber-400 font-medium">{formData.email}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-300 mb-2">رمز التحقق <span className="text-red-500">*</span></label>
|
|
||||||
<div className="relative group">
|
|
||||||
<div className="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
|
||||||
<KeyRound className="w-5 h-5 text-gray-400 group-focus-within:text-amber-500" />
|
|
||||||
</div>
|
|
||||||
<input type="text" value={otpCode} maxLength={6}
|
|
||||||
onChange={(e) => setOtpCode(e.target.value)}
|
|
||||||
className="w-full pr-12 pl-4 py-3 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 focus:border-transparent text-white placeholder-gray-500 text-center tracking-[0.5em] text-xl transition-all"
|
|
||||||
placeholder="------" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="button" onClick={handleResendOTP} disabled={isLoading}
|
|
||||||
className="w-full text-center text-amber-400 hover:text-amber-300 text-sm transition-colors disabled:opacity-50">
|
|
||||||
إعادة إرسال الرمز
|
|
||||||
</button>
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ─── Navigation Buttons ─── */}
|
|
||||||
<motion.div variants={fadeInUp} className="flex gap-3 pt-4">
|
<motion.div variants={fadeInUp} className="flex gap-3 pt-4">
|
||||||
{step === 1 && (
|
{step === 1 ? (
|
||||||
<>
|
<>
|
||||||
<button type="button" onClick={() => router.push('/auth/choose-role')}
|
<button type="button" onClick={() => router.push('/auth/choose-role')}
|
||||||
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">إلغاء</button>
|
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">إلغاء</button>
|
||||||
<button type="button" onClick={handleNextStep}
|
<button type="submit"
|
||||||
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 px-4 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 transition-all">التالي</button>
|
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 px-4 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 transition-all">التالي</button>
|
||||||
</>
|
</>
|
||||||
)}
|
) : (
|
||||||
{step === 2 && (
|
|
||||||
<>
|
<>
|
||||||
<button type="button" onClick={() => setStep(1)}
|
<button type="button" onClick={() => setStep(1)}
|
||||||
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">السابق</button>
|
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">السابق</button>
|
||||||
<button type="submit" disabled={isLoading || !formData.agreeTerms}
|
<button type="submit" disabled={isLoading || !formData.agreeTerms}
|
||||||
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 px-4 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 px-4 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
{isLoading ? (
|
{isLoading ? (<div className="flex items-center justify-center gap-2"><Loader2 className="w-5 h-5 animate-spin" /><span>جاري التسجيل...</span></div>) : 'إنشاء حساب'}
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Loader2 className="w-5 h-5 animate-spin" /><span>جاري التسجيل...</span>
|
|
||||||
</div>
|
|
||||||
) : 'إنشاء حساب'}
|
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{step === 3 && (
|
|
||||||
<button type="submit" disabled={isLoading || !otpCode}
|
|
||||||
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 px-4 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Loader2 className="w-5 h-5 animate-spin" /><span>جاري التحقق...</span>
|
|
||||||
</div>
|
|
||||||
) : 'تحقق من الرمز'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</motion.form>
|
</motion.form>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
|
{/* ─── OTP Modal ─── */}
|
||||||
|
<AnimatePresence>
|
||||||
|
{showOtpModal && (
|
||||||
|
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
|
||||||
|
className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50">
|
||||||
|
<motion.div initial={{ scale: 0.9, y: 20 }} animate={{ scale: 1, y: 0 }} exit={{ scale: 0.9, y: 20 }}
|
||||||
|
className="bg-gray-900 border border-white/10 rounded-2xl w-full max-w-md p-6 shadow-2xl">
|
||||||
|
<div className="text-center mb-6">
|
||||||
|
<div className="w-16 h-16 bg-amber-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||||
|
<Shield className="w-8 h-8 text-amber-500" />
|
||||||
|
</div>
|
||||||
|
<h2 className="text-xl font-bold text-white">التحقق من البريد</h2>
|
||||||
|
<p className="text-gray-400 text-sm mt-1">تم إرسال رمز التحقق إلى</p>
|
||||||
|
<p className="text-amber-400 font-medium text-sm">{formData.email}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-6">
|
||||||
|
<label className="block text-sm font-medium text-gray-300 mb-2">رمز التحقق</label>
|
||||||
|
<div className="relative">
|
||||||
|
<div className="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
||||||
|
<KeyRound className="w-5 h-5 text-gray-400" />
|
||||||
|
</div>
|
||||||
|
<input type="text" value={otpCode} maxLength={6}
|
||||||
|
onChange={(e) => setOtpCode(e.target.value)}
|
||||||
|
className="w-full pr-12 pl-4 py-3 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500 text-white text-center tracking-[0.5em] text-xl"
|
||||||
|
placeholder="------" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<button onClick={handleVerifyOTP} disabled={isLoading || !otpCode}
|
||||||
|
className="flex-1 bg-gradient-to-r from-amber-500 to-amber-600 text-white py-3 rounded-xl font-medium hover:from-amber-600 hover:to-amber-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2">
|
||||||
|
{isLoading ? <><Loader2 className="w-5 h-5 animate-spin" /><span>جاري التحقق...</span></> : 'تحقق'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button onClick={handleResendOTP} disabled={isLoading}
|
||||||
|
className="w-full text-center text-amber-400 hover:text-amber-300 text-sm mt-3 disabled:opacity-50">
|
||||||
|
إعادة إرسال الرمز
|
||||||
|
</button>
|
||||||
|
</motion.div>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
|
</AnimatePresence>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { useState } from 'react';
|
import { useState, useRef } from 'react';
|
||||||
import { motion } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import { useRouter } from 'next/navigation';
|
import { useRouter } from 'next/navigation';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
|
import Image from 'next/image';
|
||||||
import {
|
import {
|
||||||
User, Mail, Phone, Lock, Eye, EyeOff,
|
User, Mail, Phone, Lock, Eye, EyeOff,
|
||||||
CheckCircle, XCircle, ArrowLeft, Home, Loader2,
|
CheckCircle, XCircle, ArrowLeft, Home, Loader2,
|
||||||
Shield, KeyRound
|
Shield, KeyRound, Camera, X
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast, { Toaster } from 'react-hot-toast';
|
||||||
import { addCustomer, loginWithEmail, sendEmailOTP, verifyEmail } from '../../utils/api';
|
import { addCustomer, loginWithEmail, sendEmailOTP, verifyEmail } from '../../utils/api';
|
||||||
@ -16,7 +17,8 @@ import { CustomerType, CustomerTypeLabels } from '../../enums';
|
|||||||
|
|
||||||
export default function TenantRegisterPage() {
|
export default function TenantRegisterPage() {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [step, setStep] = useState(1); // 1=form, 2=OTP
|
const [step, setStep] = useState(1); // 1=form, 2=id images
|
||||||
|
const [showOtpModal, setShowOtpModal] = useState(false);
|
||||||
const [showPassword, setShowPassword] = useState(false);
|
const [showPassword, setShowPassword] = useState(false);
|
||||||
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
const [showConfirmPassword, setShowConfirmPassword] = useState(false);
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
@ -31,13 +33,38 @@ export default function TenantRegisterPage() {
|
|||||||
agreeTerms: false
|
agreeTerms: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [idImages, setIdImages] = useState({ front: null, back: null });
|
||||||
|
const [idImagePreviews, setIdImagePreviews] = useState({ front: '', back: '' });
|
||||||
const [otpCode, setOtpCode] = useState('');
|
const [otpCode, setOtpCode] = useState('');
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
|
||||||
|
const fileInputFrontRef = useRef(null);
|
||||||
|
const fileInputBackRef = useRef(null);
|
||||||
|
|
||||||
|
const handleImageUpload = (side, file) => {
|
||||||
|
if (!file) return;
|
||||||
|
if (!file.type.startsWith('image/')) {
|
||||||
|
toast.error('الرجاء اختيار صورة صالحة');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (file.size > 5 * 1024 * 1024) {
|
||||||
|
toast.error('حجم الصورة يجب أن يكون أقل من 5 ميجابايت');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.onloadend = () => {
|
||||||
|
setIdImagePreviews(prev => ({ ...prev, [side]: reader.result }));
|
||||||
|
};
|
||||||
|
reader.readAsDataURL(file);
|
||||||
|
setIdImages(prev => ({ ...prev, [side]: file }));
|
||||||
|
console.log('[CustomerRegister] Image uploaded:', side);
|
||||||
|
toast.success('تم رفع الصورة بنجاح', { style: { background: '#dcfce7', color: '#166534' } });
|
||||||
|
};
|
||||||
|
|
||||||
const validateEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
const validateEmail = (email) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
|
||||||
const validatePhone = (phone) => /^(09|05)[0-9]{8}$/.test(phone);
|
const validatePhone = (phone) => /^(09|05)[0-9]{8}$/.test(phone);
|
||||||
|
|
||||||
const validateForm = () => {
|
const validateStep1 = () => {
|
||||||
const newErrors = {};
|
const newErrors = {};
|
||||||
if (!formData.name) newErrors.name = 'الاسم الكامل مطلوب';
|
if (!formData.name) newErrors.name = 'الاسم الكامل مطلوب';
|
||||||
else if (formData.name.length < 3) newErrors.name = 'الاسم يجب أن يكون 3 أحرف على الأقل';
|
else if (formData.name.length < 3) newErrors.name = 'الاسم يجب أن يكون 3 أحرف على الأقل';
|
||||||
@ -57,12 +84,30 @@ export default function TenantRegisterPage() {
|
|||||||
return Object.keys(newErrors).length === 0;
|
return Object.keys(newErrors).length === 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const validateStep2 = () => {
|
||||||
|
const newErrors = {};
|
||||||
|
if (!idImages.front) newErrors.front = 'صورة الوجه الأمامي للهوية مطلوبة';
|
||||||
|
if (!idImages.back) newErrors.back = 'صورة الوجه الخلفي للهوية مطلوبة';
|
||||||
|
setErrors(newErrors);
|
||||||
|
return Object.keys(newErrors).length === 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleNextStep = () => {
|
||||||
|
if (validateStep1()) {
|
||||||
|
console.log('[CustomerRegister] Step 1 valid, moving to step 2');
|
||||||
|
setStep(2);
|
||||||
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
|
} else {
|
||||||
|
toast.error('يرجى تصحيح الأخطاء في النموذج');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// ─── Main signup handler ───
|
// ─── Main signup handler ───
|
||||||
const handleSubmit = async (e) => {
|
const handleSubmit = async (e) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!validateForm()) {
|
if (!validateStep2()) {
|
||||||
toast.error('يرجى تصحيح الأخطاء في النموذج');
|
toast.error('يرجى إكمال جميع الصور المطلوبة');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!formData.agreeTerms) {
|
if (!formData.agreeTerms) {
|
||||||
@ -86,7 +131,6 @@ export default function TenantRegisterPage() {
|
|||||||
console.log('[CustomerRegister] addCustomer response:', res);
|
console.log('[CustomerRegister] addCustomer response:', res);
|
||||||
|
|
||||||
if (res.status === 200 || res.ok) {
|
if (res.status === 200 || res.ok) {
|
||||||
// ── Store temp token for OTP flow ──
|
|
||||||
const tempToken = res.data;
|
const tempToken = res.data;
|
||||||
if (tempToken) {
|
if (tempToken) {
|
||||||
AuthService.addToken(tempToken);
|
AuthService.addToken(tempToken);
|
||||||
@ -94,36 +138,26 @@ export default function TenantRegisterPage() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const apiMessage = res.message || res.data?.message;
|
const apiMessage = res.message || res.data?.message;
|
||||||
toast.success(apiMessage || 'تم إنشاء الحساب! يرجى التحقق من بريدك الإلكتروني', {
|
toast.success(apiMessage || 'تم إنشاء الحساب! يرجى التحقق من بريدك الإلكتروني', { duration: 4000 });
|
||||||
duration: 4000,
|
|
||||||
});
|
|
||||||
|
|
||||||
// ── Auto-login to trigger OTP ──
|
// Auto-login to trigger OTP
|
||||||
console.log('[CustomerRegister] Auto-login to send OTP...');
|
console.log('[CustomerRegister] Auto-login to send OTP...');
|
||||||
const loginRes = await loginWithEmail(formData.email, formData.password);
|
const loginRes = await loginWithEmail(formData.email, formData.password);
|
||||||
console.log('[CustomerRegister] login response:', loginRes);
|
console.log('[CustomerRegister] login response:', loginRes);
|
||||||
|
|
||||||
if (loginRes.status === 206) {
|
if (loginRes.status === 206) {
|
||||||
// OTP sent — move to OTP step
|
|
||||||
const otpToken = loginRes.data;
|
const otpToken = loginRes.data;
|
||||||
if (otpToken) {
|
if (otpToken) AuthService.addToken(otpToken);
|
||||||
AuthService.addToken(otpToken);
|
|
||||||
console.log('[CustomerRegister] OTP token stored');
|
|
||||||
}
|
|
||||||
const loginMsg = loginRes.message || loginRes.data?.message;
|
const loginMsg = loginRes.message || loginRes.data?.message;
|
||||||
toast(loginMsg || 'تم إرسال رمز التحقق إلى بريدك الإلكتروني', { icon: '📧' });
|
toast(loginMsg || 'تم إرسال رمز التحقق إلى بريدك الإلكتروني', { icon: '📧' });
|
||||||
setStep(2);
|
setShowOtpModal(true);
|
||||||
} else if (loginRes.status === 200) {
|
} else if (loginRes.status === 200) {
|
||||||
// Direct login success (no OTP needed)
|
|
||||||
const loginToken = loginRes.data;
|
const loginToken = loginRes.data;
|
||||||
if (loginToken) {
|
if (loginToken) AuthService.addToken(loginToken);
|
||||||
AuthService.addToken(loginToken);
|
|
||||||
}
|
|
||||||
toast.success(loginRes.message || 'تم تسجيل الدخول بنجاح!');
|
toast.success(loginRes.message || 'تم تسجيل الدخول بنجاح!');
|
||||||
router.push('/');
|
router.push('/');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Registration failed
|
|
||||||
const errMsg = res.message || res.data?.message || 'فشل في إنشاء الحساب';
|
const errMsg = res.message || res.data?.message || 'فشل في إنشاء الحساب';
|
||||||
console.error('[CustomerRegister] Registration failed:', errMsg);
|
console.error('[CustomerRegister] Registration failed:', errMsg);
|
||||||
toast.error(errMsg);
|
toast.error(errMsg);
|
||||||
@ -151,17 +185,11 @@ export default function TenantRegisterPage() {
|
|||||||
console.log('[CustomerRegister] VerifyEmail response:', res);
|
console.log('[CustomerRegister] VerifyEmail response:', res);
|
||||||
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
// ── Verified! Remove temp token, redirect to login ──
|
|
||||||
AuthService.deleteToken();
|
AuthService.deleteToken();
|
||||||
console.log('[CustomerRegister] Temp token removed after verification');
|
console.log('[CustomerRegister] Temp token removed after verification');
|
||||||
|
toast.success(res.message || 'تم التحقق من البريد الإلكتروني بنجاح!', { duration: 3000 });
|
||||||
toast.success(res.message || 'تم التحقق من البريد الإلكتروني بنجاح!', {
|
setShowOtpModal(false);
|
||||||
duration: 3000,
|
setTimeout(() => router.push('/login'), 1500);
|
||||||
});
|
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
router.push('/login');
|
|
||||||
}, 1500);
|
|
||||||
} else {
|
} else {
|
||||||
const errMsg = res.message || res.data?.message || 'رمز التحقق غير صحيح';
|
const errMsg = res.message || res.data?.message || 'رمز التحقق غير صحيح';
|
||||||
console.error('[CustomerRegister] Verification failed:', errMsg);
|
console.error('[CustomerRegister] Verification failed:', errMsg);
|
||||||
@ -175,11 +203,9 @@ export default function TenantRegisterPage() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// ─── Resend OTP ───
|
|
||||||
const handleResendOTP = async () => {
|
const handleResendOTP = async () => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
console.log('[CustomerRegister] Resending email OTP...');
|
console.log('[CustomerRegister] Resending email OTP...');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await sendEmailOTP();
|
await sendEmailOTP();
|
||||||
toast.success('تم إرسال رمز تحقق جديد');
|
toast.success('تم إرسال رمز تحقق جديد');
|
||||||
@ -205,30 +231,19 @@ export default function TenantRegisterPage() {
|
|||||||
<div className="min-h-screen bg-gradient-to-br from-gray-950 via-gray-900 to-gray-950 flex items-center justify-center p-4 relative overflow-hidden">
|
<div className="min-h-screen bg-gradient-to-br from-gray-950 via-gray-900 to-gray-950 flex items-center justify-center p-4 relative overflow-hidden">
|
||||||
<Toaster position="top-center" reverseOrder={false} />
|
<Toaster position="top-center" reverseOrder={false} />
|
||||||
|
|
||||||
{/* Background blobs */}
|
|
||||||
<div className="absolute inset-0 overflow-hidden">
|
<div className="absolute inset-0 overflow-hidden">
|
||||||
{[...Array(20)].map((_, i) => (
|
{[...Array(20)].map((_, i) => (
|
||||||
<motion.div
|
<motion.div key={i} className="absolute rounded-full bg-blue-500/10"
|
||||||
key={i}
|
style={{ left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`, width: Math.random() * 200 + 50, height: Math.random() * 200 + 50 }}
|
||||||
className="absolute rounded-full bg-blue-500/10"
|
|
||||||
style={{
|
|
||||||
left: `${Math.random() * 100}%`, top: `${Math.random() * 100}%`,
|
|
||||||
width: Math.random() * 200 + 50, height: Math.random() * 200 + 50,
|
|
||||||
}}
|
|
||||||
animate={{ x: [0, Math.random() * 100 - 50, 0], y: [0, Math.random() * 100 - 50, 0] }}
|
animate={{ x: [0, Math.random() * 100 - 50, 0], y: [0, Math.random() * 100 - 50, 0] }}
|
||||||
transition={{ duration: Math.random() * 15 + 15, repeat: Infinity, ease: "linear" }}
|
transition={{ duration: Math.random() * 15 + 15, repeat: Infinity, ease: "linear" }} />
|
||||||
/>
|
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<motion.div
|
<motion.div initial={{ opacity: 0, scale: 0.95 }} animate={{ opacity: 1, scale: 1 }} transition={{ duration: 0.5 }}
|
||||||
initial={{ opacity: 0, scale: 0.95 }}
|
className="relative z-10 w-full max-w-md">
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
{/* Back */}
|
||||||
transition={{ duration: 0.5 }}
|
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} className="mb-8">
|
||||||
className="relative z-10 w-full max-w-md"
|
|
||||||
>
|
|
||||||
{/* Back link */}
|
|
||||||
<motion.div initial={{ opacity: 0, x: -20 }} animate={{ opacity: 1, x: 0 }} className="absolute -top-16 left-0">
|
|
||||||
<Link href="/auth/choose-role" className="flex items-center gap-2 text-gray-400 hover:text-white transition-colors group">
|
<Link href="/auth/choose-role" className="flex items-center gap-2 text-gray-400 hover:text-white transition-colors group">
|
||||||
<motion.div whileHover={{ x: -5 }}><ArrowLeft className="w-4 h-4" /></motion.div>
|
<motion.div whileHover={{ x: -5 }}><ArrowLeft className="w-4 h-4" /></motion.div>
|
||||||
<span>العودة</span>
|
<span>العودة</span>
|
||||||
@ -236,43 +251,36 @@ export default function TenantRegisterPage() {
|
|||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{/* Progress */}
|
{/* Progress */}
|
||||||
<div className="mb-6 mt-4 flex gap-2">
|
<div className="mb-6 flex gap-2">
|
||||||
{[1, 2].map((s) => (
|
{[1, 2].map((s) => (
|
||||||
<motion.div key={s} className={`h-2 flex-1 rounded-full ${step >= s ? 'bg-blue-500' : 'bg-gray-700'}`} animate={{ scaleX: step >= s ? 1 : 0.5 }} />
|
<motion.div key={s} className={`h-2 flex-1 rounded-full ${step >= s ? 'bg-blue-500' : 'bg-gray-700'}`} animate={{ scaleX: step >= s ? 1 : 0.5 }} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="bg-white/5 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/10 overflow-hidden">
|
<div className="bg-white/5 backdrop-blur-xl rounded-3xl shadow-2xl border border-white/10 overflow-hidden">
|
||||||
{/* Header */}
|
|
||||||
<div className="bg-gradient-to-r from-blue-500 to-blue-600 p-8 text-center relative overflow-hidden">
|
<div className="bg-gradient-to-r from-blue-500 to-blue-600 p-8 text-center relative overflow-hidden">
|
||||||
<motion.div initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ delay: 0.2, type: "spring" }}
|
<motion.div initial={{ scale: 0 }} animate={{ scale: 1 }} transition={{ delay: 0.2, type: "spring" }}
|
||||||
className="absolute -top-10 -right-10 w-40 h-40 bg-white/10 rounded-full" />
|
className="absolute -top-10 -right-10 w-40 h-40 bg-white/10 rounded-full" />
|
||||||
<motion.div initial={{ y: 20, opacity: 0 }} animate={{ y: 0, opacity: 1 }} className="relative z-10">
|
<motion.div initial={{ y: 20, opacity: 0 }} animate={{ y: 0, opacity: 1 }} className="relative z-10">
|
||||||
<motion.div
|
<motion.div animate={{ rotate: [0, 10, -10, 0] }} transition={{ duration: 2, repeat: Infinity }}
|
||||||
animate={{ rotate: [0, 10, -10, 0] }}
|
className="w-20 h-20 mx-auto mb-4 bg-white/20 rounded-2xl flex items-center justify-center backdrop-blur-sm">
|
||||||
transition={{ duration: 2, repeat: Infinity }}
|
<Home className="w-10 h-10 text-white" />
|
||||||
className="w-20 h-20 mx-auto mb-4 bg-white/20 rounded-2xl flex items-center justify-center backdrop-blur-sm"
|
|
||||||
>
|
|
||||||
{step === 2 ? <KeyRound className="w-10 h-10 text-white" /> : <Home className="w-10 h-10 text-white" />}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
<h1 className="text-3xl font-bold text-white mb-2">
|
<h1 className="text-3xl font-bold text-white mb-2">
|
||||||
{step === 1 ? 'إنشاء حساب مستأجر' : 'التحقق من البريد'}
|
{step === 1 ? 'إنشاء حساب مستأجر' : 'الوثائق الرسمية'}
|
||||||
</h1>
|
</h1>
|
||||||
<p className="text-blue-100">
|
<p className="text-blue-100">
|
||||||
{step === 1 ? 'انضم إلينا وابحث عن منزل أحلامك' : 'أدخل رمز التحقق المرسل إلى بريدك'}
|
{step === 1 ? 'انضم إلينا وابحث عن منزل أحلامك' : 'يرجى رفع صور الهوية للتحقق'}
|
||||||
</p>
|
</p>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="p-8">
|
<div className="p-8">
|
||||||
<motion.form
|
<motion.form variants={staggerContainer} initial="initial" animate="animate"
|
||||||
variants={staggerContainer}
|
onSubmit={step === 1 ? (e) => { e.preventDefault(); handleNextStep(); } : handleSubmit}
|
||||||
initial="initial"
|
className="space-y-6">
|
||||||
animate="animate"
|
|
||||||
onSubmit={step === 1 ? handleSubmit : (e) => { e.preventDefault(); handleVerifyOTP(); }}
|
{/* ─── STEP 1: Form ─── */}
|
||||||
className="space-y-6"
|
|
||||||
>
|
|
||||||
{/* ─── STEP 1: Form fields ─── */}
|
|
||||||
{step === 1 && (
|
{step === 1 && (
|
||||||
<>
|
<>
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
@ -317,20 +325,15 @@ export default function TenantRegisterPage() {
|
|||||||
{errors.phone && <p className="text-red-500 text-sm mt-1">{errors.phone}</p>}
|
{errors.phone && <p className="text-red-500 text-sm mt-1">{errors.phone}</p>}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{/* Customer Type */}
|
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
<label className="block text-sm font-medium text-gray-300 mb-2">نوع العميل <span className="text-red-500">*</span></label>
|
<label className="block text-sm font-medium text-gray-300 mb-2">نوع العميل <span className="text-red-500">*</span></label>
|
||||||
<select
|
<select value={formData.customerType}
|
||||||
value={formData.customerType}
|
|
||||||
onChange={(e) => setFormData({...formData, customerType: e.target.value})}
|
onChange={(e) => setFormData({...formData, customerType: e.target.value})}
|
||||||
className="w-full py-3 px-4 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white appearance-none cursor-pointer"
|
className="w-full py-3 px-4 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white appearance-none cursor-pointer">
|
||||||
>
|
|
||||||
{Object.entries(CustomerTypeLabels).map(([value, label]) => (
|
{Object.entries(CustomerTypeLabels).map(([value, label]) => (
|
||||||
<option key={value} value={value} className="bg-gray-900 text-white">{label}</option>
|
<option key={value} value={value} className="bg-gray-900 text-white">{label}</option>
|
||||||
))}
|
))}
|
||||||
</select>
|
</select>
|
||||||
<p className="text-xs text-gray-500 mt-1">المحدد: {CustomerTypeLabels[formData.customerType]}</p>
|
|
||||||
<p className="text-xs text-gray-600">[Console] customerType = {formData.customerType}</p>
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
<motion.div variants={fadeInUp}>
|
<motion.div variants={fadeInUp}>
|
||||||
@ -344,7 +347,7 @@ export default function TenantRegisterPage() {
|
|||||||
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.password ? 'border-red-500' : 'border-gray-700'}`}
|
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.password ? 'border-red-500' : 'border-gray-700'}`}
|
||||||
placeholder="أدخل كلمة المرور" />
|
placeholder="أدخل كلمة المرور" />
|
||||||
<button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
<button type="button" onClick={() => setShowPassword(!showPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
||||||
{showPassword ? <EyeOff className="w-5 h-5 text-gray-400 hover:text-gray-300" /> : <Eye className="w-5 h-5 text-gray-400 hover:text-gray-300" />}
|
{showPassword ? <EyeOff className="w-5 h-5 text-gray-400" /> : <Eye className="w-5 h-5 text-gray-400" />}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{errors.password && <p className="text-red-500 text-sm mt-1">{errors.password}</p>}
|
{errors.password && <p className="text-red-500 text-sm mt-1">{errors.password}</p>}
|
||||||
@ -361,7 +364,7 @@ export default function TenantRegisterPage() {
|
|||||||
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.confirmPassword ? 'border-red-500' : 'border-gray-700'}`}
|
className={`w-full pr-12 pl-12 py-3 bg-white/5 border rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white placeholder-gray-500 transition-all ${errors.confirmPassword ? 'border-red-500' : 'border-gray-700'}`}
|
||||||
placeholder="أعد إدخال كلمة المرور" />
|
placeholder="أعد إدخال كلمة المرور" />
|
||||||
<button type="button" onClick={() => setShowConfirmPassword(!showConfirmPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
<button type="button" onClick={() => setShowConfirmPassword(!showConfirmPassword)} className="absolute inset-y-0 left-0 pl-3 flex items-center">
|
||||||
{showConfirmPassword ? <EyeOff className="w-5 h-5 text-gray-400 hover:text-gray-300" /> : <Eye className="w-5 h-5 text-gray-400 hover:text-gray-300" />}
|
{showConfirmPassword ? <EyeOff className="w-5 h-5 text-gray-400" /> : <Eye className="w-5 h-5 text-gray-400" />}
|
||||||
</button>
|
</button>
|
||||||
{formData.confirmPassword && (
|
{formData.confirmPassword && (
|
||||||
<div className="absolute inset-y-0 left-12 flex items-center">
|
<div className="absolute inset-y-0 left-12 flex items-center">
|
||||||
@ -371,11 +374,52 @@ export default function TenantRegisterPage() {
|
|||||||
</div>
|
</div>
|
||||||
{errors.confirmPassword && <p className="text-red-500 text-sm mt-1">{errors.confirmPassword}</p>}
|
{errors.confirmPassword && <p className="text-red-500 text-sm mt-1">{errors.confirmPassword}</p>}
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* ─── STEP 2: ID Images ─── */}
|
||||||
|
{step === 2 && (
|
||||||
|
<>
|
||||||
|
<motion.div variants={fadeInUp}>
|
||||||
|
<label className="block text-sm font-medium text-gray-300 mb-2">صورة الهوية - الوجه الأمامي <span className="text-red-500">*</span></label>
|
||||||
|
<div onClick={() => fileInputFrontRef.current?.click()}
|
||||||
|
className={`relative border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all ${idImagePreviews.front ? 'border-green-500 bg-green-500/10' : errors.front ? 'border-red-500 bg-red-500/10' : 'border-gray-700 hover:border-blue-500 hover:bg-white/5'}`}>
|
||||||
|
<input ref={fileInputFrontRef} type="file" accept="image/*" onChange={(e) => handleImageUpload('front', e.target.files?.[0])} className="hidden" />
|
||||||
|
{idImagePreviews.front ? (
|
||||||
|
<div className="relative">
|
||||||
|
<Image src={idImagePreviews.front} alt="Front ID" width={200} height={120} className="mx-auto rounded-lg object-cover" />
|
||||||
|
<button onClick={(e) => { e.stopPropagation(); setIdImages(prev => ({...prev, front: null})); setIdImagePreviews(prev => ({...prev, front: ''})); }}
|
||||||
|
className="absolute -top-2 -right-2 w-6 h-6 bg-red-500 rounded-full flex items-center justify-center hover:bg-red-600">
|
||||||
|
<X className="w-4 h-4 text-white" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (<><Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" /><p className="text-gray-400">اضغط لرفع الصورة</p><p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p></>)}
|
||||||
|
</div>
|
||||||
|
{errors.front && <p className="text-red-500 text-sm mt-1">{errors.front}</p>}
|
||||||
|
</motion.div>
|
||||||
|
|
||||||
|
<motion.div variants={fadeInUp}>
|
||||||
|
<label className="block text-sm font-medium text-gray-300 mb-2">صورة الهوية - الوجه الخلفي <span className="text-red-500">*</span></label>
|
||||||
|
<div onClick={() => fileInputBackRef.current?.click()}
|
||||||
|
className={`relative border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all ${idImagePreviews.back ? 'border-green-500 bg-green-500/10' : errors.back ? 'border-red-500 bg-red-500/10' : 'border-gray-700 hover:border-blue-500 hover:bg-white/5'}`}>
|
||||||
|
<input ref={fileInputBackRef} type="file" accept="image/*" onChange={(e) => handleImageUpload('back', e.target.files?.[0])} className="hidden" />
|
||||||
|
{idImagePreviews.back ? (
|
||||||
|
<div className="relative">
|
||||||
|
<Image src={idImagePreviews.back} alt="Back ID" width={200} height={120} className="mx-auto rounded-lg object-cover" />
|
||||||
|
<button onClick={(e) => { e.stopPropagation(); setIdImages(prev => ({...prev, back: null})); setIdImagePreviews(prev => ({...prev, back: ''})); }}
|
||||||
|
className="absolute -top-2 -right-2 w-6 h-6 bg-red-500 rounded-full flex items-center justify-center hover:bg-red-600">
|
||||||
|
<X className="w-4 h-4 text-white" />
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
) : (<><Camera className="w-12 h-12 text-gray-500 mx-auto mb-3" /><p className="text-gray-400">اضغط لرفع الصورة</p><p className="text-xs text-gray-500 mt-2">JPEG, PNG, JPG • حتى 5MB</p></>)}
|
||||||
|
</div>
|
||||||
|
{errors.back && <p className="text-red-500 text-sm mt-1">{errors.back}</p>}
|
||||||
|
</motion.div>
|
||||||
|
|
||||||
<motion.div variants={fadeInUp} className="flex items-center gap-2">
|
<motion.div variants={fadeInUp} className="flex items-center gap-2">
|
||||||
<input type="checkbox" id="terms" checked={formData.agreeTerms}
|
<input type="checkbox" id="terms" checked={formData.agreeTerms}
|
||||||
onChange={(e) => setFormData({...formData, agreeTerms: e.target.checked})}
|
onChange={(e) => setFormData({...formData, agreeTerms: e.target.checked})}
|
||||||
className="w-4 h-4 rounded border-gray-600 bg-white/5 text-blue-500 focus:ring-blue-500 focus:ring-offset-0" required />
|
className="w-4 h-4 rounded border-gray-600 bg-white/5 text-blue-500 focus:ring-blue-500" required />
|
||||||
<label htmlFor="terms" className="text-sm text-gray-300">
|
<label htmlFor="terms" className="text-sm text-gray-300">
|
||||||
أوافق على <Link href="/terms" className="text-blue-400 hover:text-blue-300">شروط الاستخدام</Link> و <Link href="/privacy" className="text-blue-400 hover:text-blue-300">سياسة الخصوصية</Link>
|
أوافق على <Link href="/terms" className="text-blue-400 hover:text-blue-300">شروط الاستخدام</Link> و <Link href="/privacy" className="text-blue-400 hover:text-blue-300">سياسة الخصوصية</Link>
|
||||||
</label>
|
</label>
|
||||||
@ -383,61 +427,25 @@ export default function TenantRegisterPage() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* ─── STEP 2: OTP ─── */}
|
{/* ─── Buttons ─── */}
|
||||||
{step === 2 && (
|
|
||||||
<motion.div variants={fadeInUp} className="space-y-6">
|
|
||||||
<div className="bg-blue-500/10 border border-blue-500/20 rounded-xl p-4 text-center">
|
|
||||||
<Shield className="w-10 h-10 text-blue-500 mx-auto mb-2" />
|
|
||||||
<p className="text-gray-300 text-sm">تم إرسال رمز التحقق إلى</p>
|
|
||||||
<p className="text-blue-400 font-medium">{formData.email}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label className="block text-sm font-medium text-gray-300 mb-2">رمز التحقق <span className="text-red-500">*</span></label>
|
|
||||||
<div className="relative group">
|
|
||||||
<div className="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
|
||||||
<KeyRound className="w-5 h-5 text-gray-400 group-focus-within:text-blue-500" />
|
|
||||||
</div>
|
|
||||||
<input type="text" value={otpCode} maxLength={6}
|
|
||||||
onChange={(e) => setOtpCode(e.target.value)}
|
|
||||||
className="w-full pr-12 pl-4 py-3 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-white placeholder-gray-500 text-center tracking-[0.5em] text-xl transition-all"
|
|
||||||
placeholder="------" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<button type="button" onClick={handleResendOTP} disabled={isLoading}
|
|
||||||
className="w-full text-center text-blue-400 hover:text-blue-300 text-sm transition-colors disabled:opacity-50">
|
|
||||||
إعادة إرسال الرمز
|
|
||||||
</button>
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* ─── Navigation Buttons ─── */}
|
|
||||||
<motion.div variants={fadeInUp} className="flex gap-3 pt-4">
|
<motion.div variants={fadeInUp} className="flex gap-3 pt-4">
|
||||||
{step === 1 && (
|
{step === 1 ? (
|
||||||
<>
|
<>
|
||||||
<button type="button" onClick={() => router.push('/auth/choose-role')}
|
<button type="button" onClick={() => router.push('/auth/choose-role')}
|
||||||
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">إلغاء</button>
|
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">إلغاء</button>
|
||||||
<button type="submit" disabled={isLoading}
|
<button type="submit"
|
||||||
|
className="flex-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white py-3 px-4 rounded-xl font-medium hover:from-blue-600 hover:to-blue-700 transition-all">التالي</button>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
|
<button type="button" onClick={() => setStep(1)}
|
||||||
|
className="flex-1 py-3 px-4 bg-white/5 border border-gray-700 rounded-xl text-gray-300 hover:bg-white/10 transition-colors">السابق</button>
|
||||||
|
<button type="submit" disabled={isLoading || !formData.agreeTerms}
|
||||||
className="flex-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white py-3 px-4 rounded-xl font-medium hover:from-blue-600 hover:to-blue-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
className="flex-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white py-3 px-4 rounded-xl font-medium hover:from-blue-600 hover:to-blue-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
||||||
{isLoading ? (
|
{isLoading ? (<div className="flex items-center justify-center gap-2"><Loader2 className="w-5 h-5 animate-spin" /><span>جاري التسجيل...</span></div>) : 'إنشاء حساب'}
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Loader2 className="w-5 h-5 animate-spin" /><span>جاري التسجيل...</span>
|
|
||||||
</div>
|
|
||||||
) : 'إنشاء حساب'}
|
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{step === 2 && (
|
|
||||||
<button type="submit" disabled={isLoading || !otpCode}
|
|
||||||
className="flex-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white py-3 px-4 rounded-xl font-medium hover:from-blue-600 hover:to-blue-700 transition-all disabled:opacity-50 disabled:cursor-not-allowed">
|
|
||||||
{isLoading ? (
|
|
||||||
<div className="flex items-center justify-center gap-2">
|
|
||||||
<Loader2 className="w-5 h-5 animate-spin" /><span>جاري التحقق...</span>
|
|
||||||
</div>
|
|
||||||
) : 'تحقق من الرمز'}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
{step === 1 && (
|
{step === 1 && (
|
||||||
@ -450,6 +458,51 @@ export default function TenantRegisterPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
|
|
||||||
|
{/* ─── OTP Modal ─── */}
|
||||||
|
<AnimatePresence>
|
||||||
|
{showOtpModal && (
|
||||||
|
<motion.div initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }}
|
||||||
|
className="fixed inset-0 bg-black/60 backdrop-blur-sm flex items-center justify-center p-4 z-50">
|
||||||
|
<motion.div initial={{ scale: 0.9, y: 20 }} animate={{ scale: 1, y: 0 }} exit={{ scale: 0.9, y: 20 }}
|
||||||
|
className="bg-gray-900 border border-white/10 rounded-2xl w-full max-w-md p-6 shadow-2xl">
|
||||||
|
<div className="text-center mb-6">
|
||||||
|
<div className="w-16 h-16 bg-blue-500/20 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||||
|
<Shield className="w-8 h-8 text-blue-500" />
|
||||||
|
</div>
|
||||||
|
<h2 className="text-xl font-bold text-white">التحقق من البريد</h2>
|
||||||
|
<p className="text-gray-400 text-sm mt-1">تم إرسال رمز التحقق إلى</p>
|
||||||
|
<p className="text-blue-400 font-medium text-sm">{formData.email}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="mb-6">
|
||||||
|
<label className="block text-sm font-medium text-gray-300 mb-2">رمز التحقق</label>
|
||||||
|
<div className="relative">
|
||||||
|
<div className="absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none">
|
||||||
|
<KeyRound className="w-5 h-5 text-gray-400" />
|
||||||
|
</div>
|
||||||
|
<input type="text" value={otpCode} maxLength={6}
|
||||||
|
onChange={(e) => setOtpCode(e.target.value)}
|
||||||
|
className="w-full pr-12 pl-4 py-3 bg-white/5 border border-gray-700 rounded-xl focus:outline-none focus:ring-2 focus:ring-blue-500 text-white text-center tracking-[0.5em] text-xl"
|
||||||
|
placeholder="------" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="flex gap-3">
|
||||||
|
<button onClick={handleVerifyOTP} disabled={isLoading || !otpCode}
|
||||||
|
className="flex-1 bg-gradient-to-r from-blue-500 to-blue-600 text-white py-3 rounded-xl font-medium hover:from-blue-600 hover:to-blue-700 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2">
|
||||||
|
{isLoading ? <><Loader2 className="w-5 h-5 animate-spin" /><span>جاري التحقق...</span></> : 'تحقق'}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button onClick={handleResendOTP} disabled={isLoading}
|
||||||
|
className="w-full text-center text-blue-400 hover:text-blue-300 text-sm mt-3 disabled:opacity-50">
|
||||||
|
إعادة إرسال الرمز
|
||||||
|
</button>
|
||||||
|
</motion.div>
|
||||||
|
</motion.div>
|
||||||
|
)}
|
||||||
|
</AnimatePresence>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user