+ {/* Back Button - always visible */}
+
+
+ {/* Breadcrumb - truncates on mobile */}
+
+ router.push('/')}>خانه
+
+ { setSelectedCategory("all"); }}>کاتالوگ
{selectedCategory !== "all" && (
<>
-
- {CATEGORY_LABELS[selectedCategory] || selectedCategory}
+
+ {CATEGORY_LABELS[selectedCategory] || selectedCategory}
>
)}
-
-
-
-
+ {/* Mobile Filter Button */}
+
diff --git a/frontend/application/components/AuthModal.tsx b/frontend/application/components/AuthModal.tsx
index e38a16de..a336bc95 100644
--- a/frontend/application/components/AuthModal.tsx
+++ b/frontend/application/components/AuthModal.tsx
@@ -1,7 +1,7 @@
"use client";
import React, { useState, useEffect, useRef } from "react";
import { motion, AnimatePresence } from "motion/react";
-import { X, User, Building2, Heart, ShieldCheck, Phone, Key, LogIn, ArrowRight, RefreshCw } from "lucide-react";
+import { X, User, Building2, Heart, ShieldCheck, Phone, Key, LogIn, ArrowRight, RefreshCw, Lock } from "lucide-react";
import { useUserStore, UserRole } from "../lib/store/userStore";
import { authService } from "../lib/services/authService";
import { toast } from "sonner";
@@ -14,9 +14,10 @@ interface AuthModalProps {
export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
const { setRole, setLoggedIn, fetchProfile } = useUserStore();
- const [view, setView] = useState<"login" | "register" | "otp-phone" | "otp">("login");
+ const [view, setView] = useState<"login" | "register" | "otp-phone" | "otp" | "forgot-password" | "forgot-otp" | "reset-password">("login");
const [phoneNumber, setPhoneNumber] = useState("");
const [password, setPassword] = useState("");
+ const [newPassword, setNewPassword] = useState("");
const [email, setEmail] = useState("");
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
@@ -40,6 +41,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
setView("login");
setPhoneNumber("");
setPassword("");
+ setNewPassword("");
setEmail("");
setFirstName("");
setLastName("");
@@ -159,6 +161,67 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
}
};
+ const handleForgotSendOtp = async (e: React.FormEvent) => {
+ e.preventDefault();
+ const cleanPhone = phoneNumber.trim();
+ if (!/^09\d{9}$/.test(cleanPhone)) {
+ toast.error("شماره موبایل نامعتبر است");
+ return;
+ }
+ setIsLoading(true);
+ try {
+ const res = await authService.sendOtp(cleanPhone);
+ if ((res as any).code) {
+ toast.info(`کد تایید (تست): ${(res as any).code}`, { duration: 10000 });
+ } else {
+ toast.success("کد بازیابی رمز پیامک شد");
+ }
+ setView("forgot-otp");
+ setCountdown(120);
+ } catch (err: any) {
+ toast.error(err.message || "خطا در ارسال کد");
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const handleForgotVerifyOtp = async (e: React.FormEvent) => {
+ e.preventDefault();
+ if (otpCode.trim().length !== 5) {
+ toast.error("کد باید ۵ رقم باشد");
+ return;
+ }
+ setIsLoading(true);
+ try {
+ // Verify OTP - if success, allow password reset
+ await authService.verifyOtp(phoneNumber.trim(), otpCode.trim());
+ setView("reset-password");
+ } catch (err: any) {
+ toast.error(err.message || "کد تایید نامعتبر است");
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ const handleResetPassword = async (e: React.FormEvent) => {
+ e.preventDefault();
+ if (newPassword.length < 6) {
+ toast.error("رمز جدید باید حداقل ۶ کاراکتر باشد");
+ return;
+ }
+ setIsLoading(true);
+ try {
+ // Use authService to update password after OTP verification
+ await authService.updateProfile({ password: newPassword } as any);
+ toast.success("رمز عبور با موفقیت تغییر یافت");
+ setView("login");
+ } catch (err: any) {
+ toast.error(err.message || "خطا در تغییر رمز");
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
return (
{isOpen && (
@@ -219,10 +282,13 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
className="space-y-4"
>
-
+
setPhoneNumber(e.target.value.replace(/[^0-9]/g, ''))}
@@ -231,9 +297,12 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
/>
-
+
setPassword(e.target.value)}
@@ -242,7 +311,7 @@ export default function AuthModal({ isOpen, onClose }: AuthModalProps) {
/>
-
+
-
+
+
+
+