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:
chris 2026-04-17 15:45:46 -04:00
parent 623b237826
commit 107ef43a0e

View File

@ -82,11 +82,15 @@ export default function FeaturedProducts() {
return visible
}, [items, catOrder, catHidden])
const tabs = useMemo(() => [
const tabs = useMemo(() => {
// Category slugs already represented by an occasion tab — hide them from the regular tabs
const occasionSlugs = new Set(activeOccasions.map((o) => o.squareCategorySlug).filter(Boolean) as string[])
return [
...activeOccasions.map((o) => ({ key: o.key, label: `${o.emoji} ${o.label}`, occasion: true })),
{ key: 'all', label: 'All', occasion: false },
...productCategories.map((c) => ({ ...c, occasion: false })),
], [activeOccasions, productCategories])
...productCategories.filter((c) => !occasionSlugs.has(c.key)).map((c) => ({ ...c, occasion: false })),
]
}, [activeOccasions, productCategories])
const activeOccasion: ActiveOccasion | undefined = useMemo(
() => activeOccasions.find((o) => o.key === category),