Browse Source

feat: add QuestionPhoto component for image uploads and previews

master
parent
commit
4468e832bf
  1. 17
      src/components/Componentes/question-photo.tsx

17
src/components/Componentes/question-photo.tsx

@ -92,11 +92,15 @@ export function QuestionPhoto({
if (fileInputRef.current) {
fileInputRef.current.value = "";
}
setToastMessage(
t["Failed to load image. Please try uploading again."] ??
"Failed to load image. Please try uploading again.",
);
}, [question, setAnswerValue, t]);
// Only show the toast if the user was actively uploading;
// stale stored URLs from previous sessions fail silently.
if (isUploading || isInitiatorRef.current) {
setToastMessage(
t["Failed to load image. Please try uploading again."] ??
"Failed to load image. Please try uploading again.",
);
}
}, [question, setAnswerValue, t, isUploading]);
const uploadTmpMediaMutation = useUploadTmpMediaMutation({
onSuccess: (response) => {
@ -256,8 +260,7 @@ export function QuestionPhoto({
mediaType: "image",
source: pickerSource as any,
picker_type: pickerType as any,
returnAs: "upload",
uploadUrl: `${window.location.origin}/api/proxy?__proxyPath=/upload-tmp-media/`,
returnAs: "base64",
fieldName: "file",
allowedExtensions:
extensions.length > 0 ? extensions : ["jpg", "jpeg", "png", "webp"],

Loading…
Cancel
Save