mirror of
https://github.com/jjbrunton/Sauci.git
synced 2026-11-02 02:19:43 +00:00
fix(admin): support typed question responses
Render database-backed text, audio, photo, and choice responses across admin activity and user detail views. Add support for the both_answered match state while retaining legacy swipe behavior.
This commit is contained in:
1 parent
01bb8225ae
commit
6df9442cd0
6 files changed
+175
-42
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import type { AnswerType, QuestionType } from '@sauci/shared';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { formatAdminResponse, QUESTION_TYPE_LABELS, type AdminResponseData } from '@/lib/questionResponses';
|
||||
|
||||
interface ResponseAnswerProps {
|
||||
answer: AnswerType;
|
||||
questionType?: QuestionType | null;
|
||||
responseData?: AdminResponseData;
|
||||
}
|
||||
|
||||
export function ResponseAnswer({ answer, questionType, responseData = null }: ResponseAnswerProps) {
|
||||
const formatted = formatAdminResponse(questionType, answer, responseData);
|
||||
const resolvedType = questionType ?? 'swipe';
|
||||
|
||||
return (
|
||||
<div className="min-w-0 space-y-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-sm font-medium">{formatted.label}</span>
|
||||
{resolvedType !== 'swipe' && (
|
||||
<Badge variant="outline" className="text-[10px] font-normal">
|
||||
{QUESTION_TYPE_LABELS[resolvedType]}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
{formatted.detail && (
|
||||
<p className="max-w-md whitespace-pre-wrap break-words text-xs text-muted-foreground">
|
||||
{formatted.detail}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user