Two gaps discovered during the first live grill-session of IDEA-002:
the agent posted a question, but the user had no UI to answer it.
1. Idea-questions only appeared on the Timeline-tab as read-only entries
2. Notifications-bell fetched + handled story-questions only
This fix:
**Inline answer-form in IdeaTimeline** (components/ideas/idea-timeline.tsx)
- Open questions now render an AnswerForm directly under the question text
- Multi-choice options become clickable buttons (one-click submit); free-text
fallback via collapsed details/textarea
- Plain free-text questions render textarea + Verzend
- Calls existing answerQuestion server-action; toast + router.refresh on success
**Notifications-bell extended for idea-questions**
- stores/notifications-store.ts: NotificationQuestion → discriminated union
(kind: 'story' | 'idea'); forYouCount treats idea-questions as always-for-you
(idea is strictly user_id-only — only the owner sees them)
- components/notifications/notifications-bridge.tsx: parallel fetch of
story-questions (productAccessFilter) + idea-questions (idea.user_id ===
session.userId); merged + sorted by created_at
- components/notifications/notifications-sheet.tsx: renders idea_code/title
for kind='idea'
- components/notifications/answer-modal.tsx: header + open-link branch on
kind (idea → /ideas/[id]?tab=timeline; story → existing /sprint link)
- lib/realtime/use-notifications-realtime.ts: idea-question events also
trigger close+reconnect on 'open' (loads fresh detail) and remove(id) on
non-open — same pattern story-questions already use
- components/shared/notifications-bell.tsx: badge counts idea-questions as
for-you regardless of assignee
**Security gap closed (actions/questions.ts answerQuestion)**
Before: accepted any answer if user has product-access.
After: idea-questions require idea.user_id === session.userId; story-
questions keep the existing productAccessFilter path. (Prisma 7 rejects
\`{ not: null }\` in WHERE; routing happens app-level after a single fetch.)
Tests: 546/546 still green.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
57 lines
2.1 KiB
TypeScript
57 lines
2.1 KiB
TypeScript
'use client'
|
|
|
|
// ST-1105: Bell-icon in de NavBar met badge van het aantal open Claude-vragen
|
|
// voor de ingelogde gebruiker (M11).
|
|
//
|
|
// Klik opent <NotificationsSheet />. Story-assignee-vragen ("voor jou") worden
|
|
// gemarkeerd met een ring-accent op het badge zodat ook bij gelijke totaal-
|
|
// count de prioriteit zichtbaar is.
|
|
|
|
import { Bell } from 'lucide-react'
|
|
import { useNotificationsStore } from '@/stores/notifications-store'
|
|
import { NotificationsSheet } from '@/components/notifications/notifications-sheet'
|
|
import { cn } from '@/lib/utils'
|
|
|
|
interface NotificationsBellProps {
|
|
currentUserId: string
|
|
isDemo: boolean
|
|
}
|
|
|
|
export function NotificationsBell({ currentUserId, isDemo }: NotificationsBellProps) {
|
|
const total = useNotificationsStore((s) => s.questions.length)
|
|
const forYou = useNotificationsStore((s) =>
|
|
s.questions.filter((q) =>
|
|
// story-question: assignee match; idea-question: altijd voor jou (privé)
|
|
q.kind === 'idea' ? true : q.assignee_id === currentUserId,
|
|
).length,
|
|
)
|
|
|
|
return (
|
|
<NotificationsSheet
|
|
currentUserId={currentUserId}
|
|
isDemo={isDemo}
|
|
trigger={
|
|
<button
|
|
type="button"
|
|
aria-label={`Notificaties — ${total} open vragen${forYou > 0 ? `, ${forYou} voor jou` : ''}`}
|
|
className="relative inline-flex h-9 w-9 items-center justify-center rounded-full hover:bg-surface-container focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary focus-visible:ring-offset-2 focus-visible:ring-offset-background"
|
|
>
|
|
<Bell className="h-5 w-5 text-foreground" />
|
|
{total > 0 && (
|
|
<span
|
|
role="status"
|
|
className={cn(
|
|
'absolute -right-0.5 -top-0.5 inline-flex h-4 min-w-4 items-center justify-center rounded-full px-1 text-[10px] font-medium leading-none',
|
|
forYou > 0
|
|
? 'bg-error text-error-foreground ring-2 ring-background'
|
|
: 'bg-primary text-primary-foreground',
|
|
)}
|
|
>
|
|
{total > 9 ? '9+' : total}
|
|
</span>
|
|
)}
|
|
</button>
|
|
}
|
|
/>
|
|
)
|
|
}
|