feat: improve form response experience
This commit is contained in:
@@ -17,6 +17,7 @@ import { ScrollArea } from "@/components/ui/scroll-area";
|
||||
import Image from 'next/image';
|
||||
import { stripHtml } from "@/lib/utils";
|
||||
import { HtmlDisplay } from "@/components/html-display";
|
||||
import { formatStoredAnswer } from "@/lib/form-answer-values";
|
||||
|
||||
interface Question {
|
||||
id: string;
|
||||
@@ -94,15 +95,16 @@ export default function SubmissionDetailClient({
|
||||
{/* Answers List */}
|
||||
<div className="space-y-4">
|
||||
{questions.map((q) => {
|
||||
const ansValue = answers[q.id] || "";
|
||||
const rawAnswerValue = answers[q.id] || "";
|
||||
const answerValue = formatStoredAnswer(rawAnswerValue, q.type);
|
||||
|
||||
const wasEdited = editHistory.some(
|
||||
(edit) => (edit.oldAnswers[q.id] ?? "") !== ansValue
|
||||
(edit) => (edit.oldAnswers[q.id] ?? "") !== rawAnswerValue
|
||||
);
|
||||
|
||||
const qAnswerHistory = editHistory.map((edit) => ({
|
||||
editedAt: edit.editedAt,
|
||||
answer: edit.oldAnswers[q.id] ?? "",
|
||||
answer: formatStoredAnswer(edit.oldAnswers[q.id], q.type),
|
||||
}));
|
||||
|
||||
return (
|
||||
@@ -135,7 +137,7 @@ export default function SubmissionDetailClient({
|
||||
)}
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{ansValue ? (
|
||||
{answerValue ? (
|
||||
<div className="flex items-start justify-between gap-4 p-3 bg-muted rounded-md group">
|
||||
<div className="flex flex-col min-w-0">
|
||||
{wasEdited && (
|
||||
@@ -144,14 +146,14 @@ export default function SubmissionDetailClient({
|
||||
</span>
|
||||
)}
|
||||
<span className="text-sm whitespace-pre-wrap break-all leading-relaxed">
|
||||
{ansValue}
|
||||
{answerValue}
|
||||
</span>
|
||||
</div>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"
|
||||
onClick={() => handleCopy(ansValue, q.id)}
|
||||
onClick={() => handleCopy(answerValue, q.id)}
|
||||
>
|
||||
{copiedId === q.id ? (
|
||||
<Check className="w-4 h-4 text-green-500" />
|
||||
|
||||
Reference in New Issue
Block a user