feat: complete url modal/tab deeplinking, standardized inputs, and sync dynamic menu
Deploy Canina / deploy (push) Successful in 1m44s
Deploy Canina / deploy (push) Successful in 1m44s
This commit is contained in:
1 parent
33c1bee483
commit
5029edaaeb
9 files changed
+454
-70
No files matched your search
@@ -79,6 +79,61 @@ export default function Header({
|
||||
}
|
||||
]);
|
||||
|
||||
interface HeaderMenuItem {
|
||||
id: string;
|
||||
label: string;
|
||||
href: string;
|
||||
icon?: string;
|
||||
children?: { id: string; label: string; href: string }[];
|
||||
}
|
||||
|
||||
const [headerNavItems, setHeaderNavItems] = useState<HeaderMenuItem[]>([
|
||||
{
|
||||
id: 'category-mega',
|
||||
label: 'دستهبندی درمانی محصولات',
|
||||
href: '/shop?view=symptoms',
|
||||
icon: 'Pill',
|
||||
},
|
||||
{
|
||||
id: 'products',
|
||||
label: 'فروشگاه و محصولات',
|
||||
href: '/shop',
|
||||
children: [
|
||||
{ id: 'shop-all', label: 'فروشگاه تخصصی محصولات کنینا', href: '/shop' },
|
||||
{ id: 'catalog', label: 'کاتالوگ دیجیتال و راهنمای بالینی', href: '/catalog' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'science',
|
||||
label: 'دانشنامه و آکادمی',
|
||||
href: '/wiki',
|
||||
children: [
|
||||
{ id: 'wiki', label: 'دانشنامه علمی کنینا', href: '/wiki' },
|
||||
{ id: 'blog', label: 'مجله سلامت پت (وبلاگ)', href: '/blog' },
|
||||
{ id: 'videos', label: 'آکادمی ویدئویی و مشاوره دامپزشک', href: '/videos' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'tools',
|
||||
label: 'ابزارهای هوشمند',
|
||||
href: '/profile',
|
||||
children: [
|
||||
{ id: 'profile', label: 'شناسنامه و سوابق سلامت پت', href: '/profile' },
|
||||
{ id: 'dashboard', label: 'پایش هوشمند مصرف مکملها', href: '/dashboard' },
|
||||
],
|
||||
},
|
||||
{
|
||||
id: 'company',
|
||||
label: 'درباره کنینا و تماس',
|
||||
href: '/about',
|
||||
children: [
|
||||
{ id: 'about', label: 'درباره کمپانی کنینا آلمان', href: '/about' },
|
||||
{ id: 'trust-seals', label: 'نمادهای اعتماد و مجوزهای رسمی', href: '/trust-seals' },
|
||||
{ id: 'contact', label: 'تماس با مرکز پشتیبانی', href: '/contact' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
const [isMounted, setIsMounted] = useState(false);
|
||||
useEffect(() => {
|
||||
Promise.resolve().then(() => setIsMounted(true));
|
||||
@@ -92,24 +147,35 @@ export default function Header({
|
||||
const isCartDisabled = isCatalogMode || isCatalogDisableCart;
|
||||
|
||||
useEffect(() => {
|
||||
const loadNavFilters = async () => {
|
||||
const loadDynamicNav = async () => {
|
||||
try {
|
||||
const data = await productService.getNavigationFilters();
|
||||
if (data && data.length > 0) {
|
||||
setMenuItems(data.map(item => ({
|
||||
id: item.slug,
|
||||
title: item.name,
|
||||
icon: MENU_ICONS[item.slug] || <Pill className="w-5 h-5" />,
|
||||
solutions: item.symptoms || []
|
||||
})));
|
||||
const [filtersRes, menuRes] = await Promise.allSettled([
|
||||
productService.getNavigationFilters(),
|
||||
fetch(`${process.env.NEXT_PUBLIC_API_URL || '/api'}/menu/type/HEADER`).then((r) => r.json()),
|
||||
]);
|
||||
|
||||
if (filtersRes.status === 'fulfilled' && filtersRes.value && filtersRes.value.length > 0) {
|
||||
setMenuItems(
|
||||
filtersRes.value.map((item) => ({
|
||||
id: item.slug,
|
||||
title: item.name,
|
||||
icon: MENU_ICONS[item.slug] || <Pill className="w-5 h-5" />,
|
||||
solutions: item.symptoms || [],
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
if (menuRes.status === 'fulfilled' && Array.isArray(menuRes.value) && menuRes.value.length > 0) {
|
||||
setHeaderNavItems(menuRes.value);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Failed to load navigation filters:', err);
|
||||
console.error('Failed to load navigation data:', err);
|
||||
}
|
||||
};
|
||||
loadNavFilters();
|
||||
loadDynamicNav();
|
||||
}, []);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
function handleClickOutside(event: MouseEvent) {
|
||||
if (userProfileRef.current && !userProfileRef.current.contains(event.target as Node)) {
|
||||
|
||||
Reference in new issue
Block a user