feat(settings): add admin toggle for prescription upload button and bind to header
E2E Playwright Tests / Run Full E2E & Security Suites (push) Waiting to run
Deploy Canina / deploy (push) Has been cancelled

This commit is contained in:
parsa aghaei committed 2026-08-26 14:32:30 +03:30
1 parent 3109e30fd7
commit 0132cce0cb
13 files changed
+5099 -4983

No files matched your search

@@ -33,6 +33,7 @@ export default function SystemSettingsPage() {
CATALOG_ALLOW_CART: 'false',
CATALOG_ALLOW_CHECKOUT: 'false',
CATALOG_PREORDER_BTN: 'false',
PRESCRIPTION_UPLOAD_ENABLED: 'true',
});
const [isLoading, setIsLoading] = useState(true);
@@ -64,6 +65,7 @@ export default function SystemSettingsPage() {
CATALOG_ALLOW_CART: d.CATALOG_ALLOW_CART || 'false',
CATALOG_ALLOW_CHECKOUT: d.CATALOG_ALLOW_CHECKOUT || 'false',
CATALOG_PREORDER_BTN: d.CATALOG_PREORDER_BTN || 'false',
PRESCRIPTION_UPLOAD_ENABLED: d.PRESCRIPTION_UPLOAD_ENABLED !== undefined ? d.PRESCRIPTION_UPLOAD_ENABLED : 'true',
});
}
})
@@ -310,6 +312,35 @@ export default function SystemSettingsPage() {
</label>
</div>
{/* Prescription Upload Button Toggle */}
<div className="flex items-center justify-between p-4 bg-emerald-50/60 rounded-2xl border border-emerald-200/80 md:col-span-2">
<div className="flex items-center gap-3">
<div className="w-10 h-10 rounded-xl bg-emerald-600 text-white flex items-center justify-center font-black">
<CheckCircle2 className="w-5 h-5" />
</div>
<div>
<h4 className="font-bold text-gray-900 text-sm">دکمه و امکان «ثبت نسخه دامپزشک» در سایت فعال باشد</h4>
<p className="text-xs text-gray-600 mt-0.5">
با غیرفعال‌سازی این گزینه، دکمه و پنجره ثبت نسخه در هدر دسکتاپ و منوی موبایل پنهان می‌شود.
</p>
</div>
</div>
<label className="relative inline-flex items-center cursor-pointer">
<input
type="checkbox"
className="sr-only peer"
checked={catalogSettings.PRESCRIPTION_UPLOAD_ENABLED !== 'false'}
onChange={(e) =>
setCatalogSettings({
...catalogSettings,
PRESCRIPTION_UPLOAD_ENABLED: e.target.checked ? 'true' : 'false',
})
}
/>
<div className="w-12 h-6 bg-gray-200 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-emerald-600"></div>
</label>
</div>
<div className="md:col-span-2">
<label className="block text-sm font-bold text-gray-700 mb-1">
شماره تماس پشتیبانی اضطراری (در زمان تعمیرات)
+32 -27
View File
@@ -46,6 +46,7 @@ export default function Header({
const [searchQuery, setSearchQuery] = useState("");
const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);
const isB2BEnabled = useSettingsStore((s) => s.getBoolean('b2bRegistrationOpen', true) && s.getBoolean('b2b_enabled', true));
const isPrescriptionEnabled = useSettingsStore((s) => s.getText('PRESCRIPTION_UPLOAD_ENABLED', 'true') !== 'false');
const [menuItems, setMenuItems] = useState<{
id: string;
@@ -239,15 +240,17 @@ export default function Header({
{/* Left Action Buttons */}
<div className="flex items-center gap-1.5 sm:gap-3 shrink-0">
{/* Prescription Upload Button (Desktop & Mobile) */}
<button
onClick={() => setIsPrescriptionModalOpen(true)}
className="flex items-center gap-1.5 px-2.5 sm:px-3 py-2 bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 rounded-xl text-[11px] sm:text-xs font-black transition-all shadow-xs cursor-pointer"
title="ثبت نسخه دامپزشک"
>
<FileHeart className="w-3.5 h-3.5 sm:w-4 sm:h-4 text-emerald-600 shrink-0" />
<span className="hidden xs:inline sm:inline">ثبت نسخه دامپزشک</span>
<span className="inline xs:hidden sm:hidden">ثبت نسخه</span>
</button>
{isPrescriptionEnabled && (
<button
onClick={() => setIsPrescriptionModalOpen(true)}
className="flex items-center gap-1.5 px-2.5 sm:px-3 py-2 bg-emerald-50 text-emerald-700 border border-emerald-200 hover:bg-emerald-100 rounded-xl text-[11px] sm:text-xs font-black transition-all shadow-xs cursor-pointer"
title="ثبت نسخه دامپزشک"
>
<FileHeart className="w-3.5 h-3.5 sm:w-4 sm:h-4 text-emerald-600 shrink-0" />
<span className="hidden xs:inline sm:inline">ثبت نسخه دامپزشک</span>
<span className="inline xs:hidden sm:hidden">ثبت نسخه</span>
</button>
)}
{/* User Account Button with Dropdown & Pets List */}
{isLoggedIn ? (
@@ -528,25 +531,27 @@ export default function Header({
</form>
{/* Direct Prescription CTA in Mobile Drawer */}
<button
type="button"
onClick={() => {
setIsMobileMenuOpen(false);
setIsPrescriptionModalOpen(true);
}}
className="w-full flex items-center justify-between p-3.5 bg-gradient-to-r from-emerald-500 to-teal-600 text-white rounded-2xl font-black text-xs shadow-md shadow-emerald-500/20 hover:brightness-105 transition-all cursor-pointer font-vazir"
>
<div className="flex items-center gap-2.5">
<div className="p-1.5 bg-white/20 rounded-xl">
<FileHeart className="w-4 h-4 text-white" />
{isPrescriptionEnabled && (
<button
type="button"
onClick={() => {
setIsMobileMenuOpen(false);
setIsPrescriptionModalOpen(true);
}}
className="w-full flex items-center justify-between p-3.5 bg-gradient-to-r from-emerald-500 to-teal-600 text-white rounded-2xl font-black text-xs shadow-md shadow-emerald-500/20 hover:brightness-105 transition-all cursor-pointer font-vazir"
>
<div className="flex items-center gap-2.5">
<div className="p-1.5 bg-white/20 rounded-xl">
<FileHeart className="w-4 h-4 text-white" />
</div>
<div className="text-right">
<div className="text-xs font-black">ثبت و استعلام نسخه دامپزشک</div>
<div className="text-[10px] text-emerald-100 font-medium">تامین فوری دارو و مکمل‌های اورجینال</div>
</div>
</div>
<div className="text-right">
<div className="text-xs font-black">ثبت و استعلام نسخه دامپزشک</div>
<div className="text-[10px] text-emerald-100 font-medium">تامین فوری دارو و مکمل‌های اورجینال</div>
</div>
</div>
<span className="text-lg">←</span>
</button>
<span className="text-lg">←</span>
</button>
)}
{/* Dynamic Menu Groups in Mobile Drawer */}
{headerNavItems.map((navGroup) => {