feat(answer-modal): conform aan dialog-pattern + entity-profile
Story 7 van PBI "Alle dialogen conform docs/patterns/dialog.md". - lib/schemas/question-answer.ts — gedeeld zod-schema + ANSWER_MAX_CHARS constant - actions/questions.ts gebruikt het gedeelde schema - AnswerModal: entityDialog* layout-classes, useDirtyCloseGuard, useDialogSubmitShortcut, DemoTooltip rond submit + multiple-choice knoppen - docs/specs/dialogs/answer-modal.md — entity-profile Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0a58557e9d
commit
4b0ab8e4b2
5 changed files with 192 additions and 100 deletions
|
|
@ -12,15 +12,10 @@
|
|||
// realtime updates voor andere clients.
|
||||
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { z } from 'zod'
|
||||
import { prisma } from '@/lib/prisma'
|
||||
import { getSession } from '@/lib/auth'
|
||||
import { productAccessFilter } from '@/lib/product-access'
|
||||
|
||||
const inputSchema = z.object({
|
||||
questionId: z.string().cuid(),
|
||||
answer: z.string().min(1).max(4000),
|
||||
})
|
||||
import { answerQuestionSchema } from '@/lib/schemas/question-answer'
|
||||
|
||||
type ActionResult = { ok: true } | { ok: false; error: string }
|
||||
|
||||
|
|
@ -32,7 +27,7 @@ export async function answerQuestion(
|
|||
if (!session.userId) return { ok: false, error: 'Niet ingelogd' }
|
||||
if (session.isDemo) return { ok: false, error: 'Niet beschikbaar in demo-modus' }
|
||||
|
||||
const parsed = inputSchema.safeParse({ questionId, answer })
|
||||
const parsed = answerQuestionSchema.safeParse({ questionId, answer })
|
||||
if (!parsed.success) {
|
||||
const first = parsed.error.issues[0]?.message ?? 'Ongeldige invoer'
|
||||
return { ok: false, error: first }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue