feat:update form

This commit is contained in:
2026-07-28 00:02:34 +07:00 Unverified
parent 0e8c816276
commit fa35f00f38
25 changed files with 919 additions and 149 deletions
+16
View File
@@ -1,6 +1,11 @@
import type { QuestionType } from "@/db/schema/form";
export type FormAnswerValue = string | string[];
export type FormAnswerPayload = {
questionId: string;
value: FormAnswerValue;
imageCdnId?: string | null;
};
export function decodeCheckboxAnswer(value: FormAnswerValue | undefined): string[] {
if (Array.isArray(value)) {
@@ -39,3 +44,14 @@ export function formatStoredAnswer(
? decodeCheckboxAnswer(value).join(", ")
: value;
}
export function answerCellValue(
value: string | undefined,
questionType: QuestionType | string,
imageCdnId?: string | null,
) {
const text = formatStoredAnswer(value, questionType);
const imageUrl = imageCdnId ? `/cdn/${imageCdnId}` : "";
if (text && imageUrl) return `${text}\n${imageUrl}`;
return text || imageUrl;
}