- new enums IdeaStatus, ClaudeJobKind, IdeaLogType
- new models Idea (with @@unique([user_id, code]) + pbi_id @unique) and IdeaLog
- User.idea_code_counter Int @default(0) for IDEA-{nnn} code generation
- ClaudeJob.task_id nullable; new idea_id + kind fields + index
- ClaudeQuestion.story_id nullable; new idea_id field + index
- existing call sites narrowed to story-questions / task-jobs (idea-paths come in T-502+)
- includes the M12 plan doc copied from /Users/janpetervisser/.claude/plans
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
// ST-1105: Mount-component voor de notifications-realtime hook (M11).
|
|
//
|
|
// Server Component dat de initial open-questions fetch't met
|
|
// productAccessFilter en doorgeeft aan een minimal client-island; client opent
|
|
// daarna de SSE-stream voor live updates.
|
|
|
|
import { prisma } from '@/lib/prisma'
|
|
import { productAccessFilter } from '@/lib/product-access'
|
|
import { NotificationsRealtimeMount } from './notifications-realtime-mount'
|
|
import type { NotificationQuestion } from '@/stores/notifications-store'
|
|
|
|
interface NotificationsBridgeProps {
|
|
userId: string
|
|
}
|
|
|
|
export async function NotificationsBridge({ userId }: NotificationsBridgeProps) {
|
|
const products = await prisma.product.findMany({
|
|
where: { archived: false, ...productAccessFilter(userId) },
|
|
select: { id: true },
|
|
})
|
|
const productIds = products.map((p) => p.id)
|
|
|
|
const openQuestions =
|
|
productIds.length === 0
|
|
? []
|
|
: await prisma.claudeQuestion.findMany({
|
|
where: {
|
|
status: 'open',
|
|
expires_at: { gt: new Date() },
|
|
product_id: { in: productIds },
|
|
story_id: { not: null },
|
|
},
|
|
orderBy: { created_at: 'desc' },
|
|
take: 100,
|
|
select: {
|
|
id: true,
|
|
product_id: true,
|
|
story_id: true,
|
|
task_id: true,
|
|
question: true,
|
|
options: true,
|
|
created_at: true,
|
|
expires_at: true,
|
|
story: { select: { code: true, title: true, assignee_id: true } },
|
|
},
|
|
})
|
|
|
|
const initial: NotificationQuestion[] = openQuestions.flatMap((q) => {
|
|
if (!q.story || q.story_id === null) return []
|
|
return [{
|
|
id: q.id,
|
|
product_id: q.product_id,
|
|
story_id: q.story_id,
|
|
task_id: q.task_id,
|
|
story_code: q.story.code,
|
|
story_title: q.story.title,
|
|
assignee_id: q.story.assignee_id,
|
|
question: q.question,
|
|
options: Array.isArray(q.options) ? (q.options as string[]) : null,
|
|
created_at: q.created_at.toISOString(),
|
|
expires_at: q.expires_at.toISOString(),
|
|
}]
|
|
})
|
|
|
|
return <NotificationsRealtimeMount initial={initial} />
|
|
}
|