feat: add view responses page
Docker Build and Push / build-and-push (push) Has been cancelled

This commit is contained in:
2026-02-22 19:03:35 +07:00
parent 4014ec802a
commit 218e8d10a0
8 changed files with 1076 additions and 7 deletions
+14 -1
View File
@@ -6,7 +6,7 @@ import {
isTokenExpired,
decodeJWT,
} from "@/lib/auth"
import type { FormSummary, FormDetail, CreateFormPayload, UpdateFormPayload, SubmitFormPayload } from "@/lib/types"
import type { FormSummary, FormDetail, CreateFormPayload, UpdateFormPayload, SubmitFormPayload, FormResponse } from "@/lib/types"
export async function refreshAccessToken(): Promise<string | null> {
if (typeof window === "undefined") return null
@@ -232,4 +232,17 @@ export async function deleteForm(id: string): Promise<void> {
const data = await res.json().catch(() => null)
throw new Error(data?.message ?? "Failed to delete form")
}
}
export async function getFormResponses(id: string): Promise<FormResponse[]> {
const res = await fetchWithAuth(`${import.meta.env.VITE_API_BASE_URL}/api/form/${id}/responses`)
if (!res.ok) {
if (res.status === 404) {
throw new Response("Form not found", { status: 404 })
}
throw new Error("Failed to fetch form responses")
}
return res.json()
}
+13
View File
@@ -75,3 +75,16 @@ export interface SubmitFormAnswer {
export interface SubmitFormPayload {
answers: SubmitFormAnswer[]
}
export interface FormResponseAnswer {
question_id: string
question_title: string
question_type: QuestionType
answer: string
}
export interface FormResponse {
id: string
submitted_at: string
answers: FormResponseAnswer[]
}