fix: hide category tab when it's already shown as an occasion tab
If a "Mothers Day" or "Graduation" occasion is active and its squareCategorySlug matches a product category, suppress the duplicate regular category tab so it doesn't appear twice in the bar. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
623b237826
commit
107ef43a0e
@ -82,11 +82,15 @@ export default function FeaturedProducts() {
|
|||||||
return visible
|
return visible
|
||||||
}, [items, catOrder, catHidden])
|
}, [items, catOrder, catHidden])
|
||||||
|
|
||||||
const tabs = useMemo(() => [
|
const tabs = useMemo(() => {
|
||||||
...activeOccasions.map((o) => ({ key: o.key, label: `${o.emoji} ${o.label}`, occasion: true })),
|
// Category slugs already represented by an occasion tab — hide them from the regular tabs
|
||||||
{ key: 'all', label: 'All', occasion: false },
|
const occasionSlugs = new Set(activeOccasions.map((o) => o.squareCategorySlug).filter(Boolean) as string[])
|
||||||
...productCategories.map((c) => ({ ...c, occasion: false })),
|
return [
|
||||||
], [activeOccasions, productCategories])
|
...activeOccasions.map((o) => ({ key: o.key, label: `${o.emoji} ${o.label}`, occasion: true })),
|
||||||
|
{ key: 'all', label: 'All', occasion: false },
|
||||||
|
...productCategories.filter((c) => !occasionSlugs.has(c.key)).map((c) => ({ ...c, occasion: false })),
|
||||||
|
]
|
||||||
|
}, [activeOccasions, productCategories])
|
||||||
|
|
||||||
const activeOccasion: ActiveOccasion | undefined = useMemo(
|
const activeOccasion: ActiveOccasion | undefined = useMemo(
|
||||||
() => activeOccasions.find((o) => o.key === category),
|
() => activeOccasions.find((o) => o.key === category),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user