- وضعیت سیستم و کنترل حالت کاتالوگ (TASK-2.14)
+ وضعیت سیستم و کنترل حالت کاتالوگ
@@ -413,23 +421,69 @@ export default function Settings() {
-
-
-
-
-
حالت کاتالوگ بدون خرید (Catalog Only Mode)
-
با فعالسازی این گزینه، دکمههای افزودن به سبد خرید غیرفعال شده و سایت به کاتالوگ آنلاین تبدیل میشود.
+
diff --git a/frontend/application/app/ClientLayout.tsx b/frontend/application/app/ClientLayout.tsx
index 88f0471c..67b8e4d0 100644
--- a/frontend/application/app/ClientLayout.tsx
+++ b/frontend/application/app/ClientLayout.tsx
@@ -42,7 +42,7 @@ export default function ClientLayout({ children }: { children: React.ReactNode }
}, [fetchProfile, fetchSettings]);
// Check Maintenance Mode (Admin / Partner bypass)
- const isMaintenanceMode = getText('maintenance_mode', 'false') === 'true';
+ const isMaintenanceMode = getText('MAINTENANCE_MODE', 'false') === 'true' || getText('maintenance_mode', 'false') === 'true';
const isAdmin = role === 'User_Partner' || (typeof window !== 'undefined' && Boolean(localStorage.getItem('adminToken')));
if (isMaintenanceMode && !isAdmin) {
diff --git a/frontend/application/components/CheckoutPage.tsx b/frontend/application/components/CheckoutPage.tsx
index 67976387..f1862a09 100644
--- a/frontend/application/components/CheckoutPage.tsx
+++ b/frontend/application/components/CheckoutPage.tsx
@@ -76,6 +76,8 @@ export default function CheckoutPage() {
}, [profile, isLoggedIn]);
const roundStep = Number(useSettingsStore((state) => state.getText('CHARITY_ROUND_STEP', '10000'))) || 10000;
+ const shippingFeeSetting = useSettingsStore((state) => state.getText('shipping_fee', '0'));
+ const shippingFee = Number(shippingFeeSetting) || 0;
const subtotal = getSubtotal();
const remainder = subtotal % roundStep;
const roundUpDiff = remainder === 0 ? roundStep : roundStep - remainder;
@@ -91,7 +93,7 @@ export default function CheckoutPage() {
};
const handleFinalize = async () => {
- const totalAmount = getTotal();
+ const totalAmount = getTotal() + shippingFee;
setLoading(true);
const activePet = getActivePet();
@@ -618,12 +620,16 @@ export default function CheckoutPage() {
)}
هزینه ارسال
- رایگان
+ {shippingFee > 0 ? (
+ {toPersian(shippingFee.toLocaleString())} تومان
+ ) : (
+ رایگان
+ )}
مبلغ نهایی
-
{toPersian(getTotal().toLocaleString())}
+
{toPersian((getTotal() + shippingFee).toLocaleString())}
تومان
@@ -728,13 +734,17 @@ export default function CheckoutPage() {
setShowAddressModal(false)}
- onSave={(newAddr) => {
- const currentAddresses = profile.addresses || [];
- const updatedAddresses = [newAddr, ...currentAddresses];
- updateProfile({ addresses: updatedAddresses });
- setSelectedAddressId(newAddr.id);
- setShowAddressModal(false);
- toast.success('آدرس جدید اضافه شد و به عنوان آدرس تحویل انتخاب گردید.');
+ onSave={async (newAddr) => {
+ try {
+ await useUserStore.getState().addAddress(newAddr);
+ const updatedProfile = useUserStore.getState().profile;
+ if (updatedProfile.addresses && updatedProfile.addresses.length > 0) {
+ setSelectedAddressId(updatedProfile.addresses[0].id);
+ }
+ setShowAddressModal(false);
+ } catch (e) {
+ console.error("Failed to add address", e);
+ }
}}
/>
diff --git a/frontend/application/components/Header.tsx b/frontend/application/components/Header.tsx
index 6071fba1..5194541e 100644
--- a/frontend/application/components/Header.tsx
+++ b/frontend/application/components/Header.tsx
@@ -43,6 +43,8 @@ export default function Header({
const [isAuthModalOpen, setIsAuthModalOpen] = useState(false);
const [isPrescriptionModalOpen, setIsPrescriptionModalOpen] = useState(false);
const [isPetSwitcherOpen, setIsPetSwitcherOpen] = useState(false);
+ const [isProfileMenuOpen, setIsProfileMenuOpen] = useState(false);
+ const userProfileRef = useRef
(null);
const [searchQuery, setSearchQuery] = useState("");
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
@@ -114,6 +116,9 @@ export default function Header({
if (petMenuRef.current && !petMenuRef.current.contains(event.target as Node)) {
setIsPetSwitcherOpen(false);
}
+ if (userProfileRef.current && !userProfileRef.current.contains(event.target as Node)) {
+ setIsProfileMenuOpen(false);
+ }
}
document.addEventListener("mousedown", handleClickOutside);
return () => document.removeEventListener("mousedown", handleClickOutside);
@@ -193,16 +198,100 @@ export default function Header({
ثبت نسخه دامپزشک
- {/* User Account Button */}
+ {/* User Account Button with Dropdown & Pets List */}
{isLoggedIn ? (
-
-
- {profile.firstName || 'حساب کاربری'}
-
+
+
+
+
+ {isProfileMenuOpen && (
+
+ {/* User info header */}
+
+
+ {profile.firstName ? `${profile.firstName} ${profile.lastName || ''}` : 'کاربر عزیز'}
+
+
{profile.mobile || profile.email}
+
+
+ {/* Pets List Section */}
+
+
+
+
+ پتهای من ({pets.length})
+
+ setIsProfileMenuOpen(false)} className="text-canina-blue hover:underline text-[10px]">
+ مدیریت
+
+
+ {pets.length > 0 ? (
+
+ {pets.map((p) => (
+
+ ))}
+
+ ) : (
+
پتی ثبت نشده است
+ )}
+
+
+
+
+ {/* Direct Navigation Links */}
+ setIsProfileMenuOpen(false)}
+ className="flex items-center gap-2 px-3 py-2 hover:bg-medical-gray-50 text-medical-gray-700 rounded-xl font-bold transition-colors"
+ >
+
+ داشبورد کاربری
+
+
+
+
+ )}
+
+
) : (