diff --git a/.claude/settings.local.json b/.claude/settings.local.json index 1268589..6359427 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -135,7 +135,14 @@ "Bash(GIT_TRACE=1 git push origin main --force)", "Bash(pkill -f \"node.exe\")", "PowerShell(Stop-Process -Name node -Force -ErrorAction SilentlyContinue)", - "Bash(find \"D:\\\\Craft2Prints\\\\src\\\\app\" -path \"*/\\\\[slug\\\\]/*\" -name \"page.tsx\" | head -10)" + "Bash(find \"D:\\\\Craft2Prints\\\\src\\\\app\" -path \"*/\\\\[slug\\\\]/*\" -name \"page.tsx\" | head -10)", + "Read(//c/Users/Lyons/OneDrive/Desktop/Products/AWD T Shirts/**)", + "Read(//c/Users/Lyons/OneDrive/Desktop/Products/**)", + "Bash(mv AT001B_* \"Polo T Shirts/\")", + "Bash(mv AT001M_* \"Polo T Shirts/\")", + "Bash(mv AT002B_* \"Striped collar/\")", + "Bash(mv AT002M_* \"Striped collar/\")", + "Bash(cd \"/c/Users/Lyons/OneDrive/Desktop/Products/AWD T Shirts\" *)" ] } } diff --git a/prisma/migrations/20260721175000_add_parent_category_support/migration.sql b/prisma/migrations/20260721175000_add_parent_category_support/migration.sql new file mode 100644 index 0000000..9e08029 --- /dev/null +++ b/prisma/migrations/20260721175000_add_parent_category_support/migration.sql @@ -0,0 +1,5 @@ +-- AlterTable +ALTER TABLE "Category" ADD COLUMN "parentId" TEXT; + +-- AddForeignKey +ALTER TABLE "Category" ADD CONSTRAINT "Category_parentId_fkey" FOREIGN KEY ("parentId") REFERENCES "Category"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index a49204e..966e6a8 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -10,10 +10,14 @@ datasource db { // Categories are their own table so you can add/rename/remove them from the admin // panel. Product.category stays a plain string (matching Category.slug) rather // than a foreign key, so nothing breaks if a category is renamed after the fact. +// Categories can be hierarchical: parentId links to a parent category. model Category { id String @id @default(cuid()) name String // display label, e.g. "Phone Cases" slug String @unique // stored key, e.g. "PHONE_CASE" — matches Product.category + parentId String? // parent category ID for hierarchical organization (e.g., "Apparel - Adults" has parent "Apparel") + parent Category? @relation("CategoryHierarchy", fields: [parentId], references: [id], onDelete: Cascade) + children Category[] @relation("CategoryHierarchy") showOnPersonalised Boolean @default(true) // appears as a filter on /made-to-order showOnProducts Boolean @default(true) // appears as a filter on /products createdAt DateTime @default(now()) diff --git a/src/app/page.tsx b/src/app/page.tsx index 4462275..c4d69b2 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -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 }));