feat(ideas): secondary_products meeladen in IdeaDto en alle queries
Voegt IdeaProduct schema toe (dependency van story-qtkvz6ly), breidt IdeaWithProduct type en IdeaDto interface uit met secondary_products array, en laadt de relatie mee in findMany/findFirst in page.tsx en REST GET. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d5333eb7d8
commit
4a929b1962
5 changed files with 32 additions and 6 deletions
|
|
@ -29,6 +29,7 @@ export default async function IdeaDetailPage({ params, searchParams }: PageProps
|
||||||
include: {
|
include: {
|
||||||
product: { select: { id: true, name: true, repo_url: true } },
|
product: { select: { id: true, name: true, repo_url: true } },
|
||||||
pbi: { select: { id: true, code: true, title: true } },
|
pbi: { select: { id: true, code: true, title: true } },
|
||||||
|
secondary_products: { include: { product: { select: { id: true, name: true } } } },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
if (!idea) notFound()
|
if (!idea) notFound()
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,10 @@ export default async function IdeasPage() {
|
||||||
const ideas = await prisma.idea.findMany({
|
const ideas = await prisma.idea.findMany({
|
||||||
where: { user_id: session.userId, archived: false },
|
where: { user_id: session.userId, archived: false },
|
||||||
orderBy: { created_at: 'desc' },
|
orderBy: { created_at: 'desc' },
|
||||||
include: { product: { select: { id: true, name: true, repo_url: true } } },
|
include: {
|
||||||
|
product: { select: { id: true, name: true, repo_url: true } },
|
||||||
|
secondary_products: { include: { product: { select: { id: true, name: true } } } },
|
||||||
|
},
|
||||||
take: 200,
|
take: 200,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,10 @@ export async function GET(request: Request) {
|
||||||
...(productIdParam ? { product_id: productIdParam } : {}),
|
...(productIdParam ? { product_id: productIdParam } : {}),
|
||||||
...(status ? { status } : {}),
|
...(status ? { status } : {}),
|
||||||
},
|
},
|
||||||
include: { product: { select: { id: true, name: true, repo_url: true } } },
|
include: {
|
||||||
|
product: { select: { id: true, name: true, repo_url: true } },
|
||||||
|
secondary_products: { include: { product: { select: { id: true, name: true } } } },
|
||||||
|
},
|
||||||
orderBy: { created_at: 'desc' },
|
orderBy: { created_at: 'desc' },
|
||||||
take: 200,
|
take: 200,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import type { Idea, IdeaStatus, Product } from '@prisma/client'
|
||||||
type IdeaWithProduct = Idea & {
|
type IdeaWithProduct = Idea & {
|
||||||
product: Pick<Product, 'id' | 'name' | 'repo_url'> | null
|
product: Pick<Product, 'id' | 'name' | 'repo_url'> | null
|
||||||
pbi?: { id: string; code: string; title: string } | null
|
pbi?: { id: string; code: string; title: string } | null
|
||||||
|
secondary_products?: { id: string; product_id: string; product: { id: string; name: string } }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IdeaDto {
|
export interface IdeaDto {
|
||||||
|
|
@ -21,6 +22,7 @@ export interface IdeaDto {
|
||||||
product: { id: string; name: string; repo_url: string | null } | null
|
product: { id: string; name: string; repo_url: string | null } | null
|
||||||
pbi_id: string | null
|
pbi_id: string | null
|
||||||
pbi?: { id: string; code: string; title: string } | null
|
pbi?: { id: string; code: string; title: string } | null
|
||||||
|
secondary_products: { id: string; product_id: string; product: { id: string; name: string } }[]
|
||||||
archived: boolean
|
archived: boolean
|
||||||
has_grill_md: boolean
|
has_grill_md: boolean
|
||||||
has_plan_md: boolean
|
has_plan_md: boolean
|
||||||
|
|
@ -39,6 +41,7 @@ export function ideaToDto(idea: IdeaWithProduct & { status: IdeaStatus }): IdeaD
|
||||||
product: idea.product,
|
product: idea.product,
|
||||||
pbi_id: idea.pbi_id,
|
pbi_id: idea.pbi_id,
|
||||||
pbi: idea.pbi ?? null,
|
pbi: idea.pbi ?? null,
|
||||||
|
secondary_products: idea.secondary_products ?? [],
|
||||||
archived: idea.archived,
|
archived: idea.archived,
|
||||||
// Geen md-content in lijst-payloads (kan groot zijn) — enkel een vlag.
|
// Geen md-content in lijst-payloads (kan groot zijn) — enkel een vlag.
|
||||||
has_grill_md: idea.grill_md !== null,
|
has_grill_md: idea.grill_md !== null,
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,7 @@ model Product {
|
||||||
claude_questions ClaudeQuestion[]
|
claude_questions ClaudeQuestion[]
|
||||||
claude_jobs ClaudeJob[]
|
claude_jobs ClaudeJob[]
|
||||||
ideas Idea[]
|
ideas Idea[]
|
||||||
|
idea_products IdeaProduct[]
|
||||||
|
|
||||||
@@unique([user_id, name])
|
@@unique([user_id, name])
|
||||||
@@unique([user_id, code])
|
@@unique([user_id, code])
|
||||||
|
|
@ -416,10 +417,11 @@ model Idea {
|
||||||
created_at DateTime @default(now())
|
created_at DateTime @default(now())
|
||||||
updated_at DateTime @updatedAt
|
updated_at DateTime @updatedAt
|
||||||
|
|
||||||
questions ClaudeQuestion[]
|
questions ClaudeQuestion[]
|
||||||
jobs ClaudeJob[]
|
jobs ClaudeJob[]
|
||||||
logs IdeaLog[]
|
logs IdeaLog[]
|
||||||
user_questions UserQuestion[]
|
user_questions UserQuestion[]
|
||||||
|
secondary_products IdeaProduct[]
|
||||||
|
|
||||||
@@unique([user_id, code])
|
@@unique([user_id, code])
|
||||||
@@index([user_id, archived, status])
|
@@index([user_id, archived, status])
|
||||||
|
|
@ -427,6 +429,20 @@ model Idea {
|
||||||
@@map("ideas")
|
@@map("ideas")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model IdeaProduct {
|
||||||
|
id String @id @default(cuid())
|
||||||
|
idea_id String
|
||||||
|
product_id String
|
||||||
|
created_at DateTime @default(now())
|
||||||
|
|
||||||
|
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||||
|
product Product @relation(fields: [product_id], references: [id], onDelete: Cascade)
|
||||||
|
|
||||||
|
@@unique([idea_id, product_id])
|
||||||
|
@@index([product_id])
|
||||||
|
@@map("idea_products")
|
||||||
|
}
|
||||||
|
|
||||||
model IdeaLog {
|
model IdeaLog {
|
||||||
id String @id @default(cuid())
|
id String @id @default(cuid())
|
||||||
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
idea Idea @relation(fields: [idea_id], references: [id], onDelete: Cascade)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue