в varimg можно загрузить картинку только если выбран own

This commit is contained in:
Nastya 2025-06-22 19:24:07 +03:00
parent f5ed7517fa
commit ac82e688c5
2 changed files with 7 additions and 5 deletions

@ -50,8 +50,8 @@ export const OwnVarimgImage = forwardRef<HTMLInputElement, OwnVarimgImageProps>(
const localImageUrl = URL.createObjectURL(file);
updateOwnVariant(variantId, "", "", fileId, localImageUrl);
// Автоматически выбираем "own" вариант при загрузке файла
updateAnswer(questionId, variantId, 0);
// Убираем автоматический выбор own варианта - загрузка возможна только при выбранном own варианте
// updateAnswer(questionId, variantId, 0);
} catch (error) {
console.error("Error uploading image:", error);
enqueueSnackbar(t("The answer was not counted"));

@ -72,7 +72,8 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
}, [variant]);
const handlePreviewAreaClick = () => {
if (ownVariantInQuestion) {
// Загрузка возможна только если own вариант выбран
if (ownVariantInQuestion && answer === ownVariantInQuestion.id) {
inputRef.current?.click();
}
};
@ -158,7 +159,7 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
</RadioGroup>
<ButtonBase
onClick={handlePreviewAreaClick}
disabled={!ownVariantInQuestion}
disabled={!ownVariantInQuestion || answer !== ownVariantInQuestion.id}
sx={{
maxWidth: "450px",
width: "100%",
@ -174,7 +175,8 @@ export const Varimg = ({ currentQuestion }: VarimgProps) => {
textAlign: "center",
position: "relative",
"&:hover": {
backgroundColor: ownVariantInQuestion ? "rgba(0,0,0,0.04)" : "transparent",
backgroundColor:
ownVariantInQuestion && answer === ownVariantInQuestion.id ? "rgba(0,0,0,0.04)" : "transparent",
},
}}
>