Feat: Add hierarchical category support for menu organization
Added parent-child relationship to categories, allowing organization
of categories into submenus (e.g., Apparel > Adults, Kids, Babies).
Changes:
- Add parentId field to Category model
- Create foreign key relationship for category hierarchy
- Update homepage to query only top-level categories (parentId = null)
- Include children categories for future use in category menus
Database migration:
- Adds parentId column to Category table
- Sets up CASCADE delete to remove children when parent is deleted
This enables menu structure like:
Apparel
- Adults
- Kids
- Babies
Drinkware
Phone Cases
etc.
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Haiku 4.5
parent
86df5a6cf0
commit
23631b1bce
+2
-1
@@ -40,8 +40,9 @@ export default async function HomePage() {
|
||||
const readyMadeCount = readyMade.length;
|
||||
|
||||
const categoryRows = await prisma.category.findMany({
|
||||
where: { showOnPersonalised: true },
|
||||
where: { showOnPersonalised: true, parentId: null },
|
||||
orderBy: { name: 'asc' },
|
||||
include: { children: { orderBy: { name: 'asc' } } },
|
||||
});
|
||||
const categories = categoryRows.map((c) => ({ label: c.name, value: c.slug }));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user