фикс первого безтипового вопроса в списке из юзэффект и возможность удаления картинки из результата
This commit is contained in:
parent
0831da8403
commit
e41dc330bd
@ -28,7 +28,9 @@ export const DraggableList = ({
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isLoading && quiz && !filteredQuestions.length) {
|
if (!isLoading && quiz && !filteredQuestions.length) {
|
||||||
createUntypedQuestion(Number(quiz.id));
|
console.log("useEffect", quiz)
|
||||||
|
console.log(Number(quiz.backendId))
|
||||||
|
createUntypedQuestion(Number(quiz.backendId));
|
||||||
}
|
}
|
||||||
}, [quiz, filteredQuestions]);
|
}, [quiz, filteredQuestions]);
|
||||||
|
|
||||||
|
@ -125,6 +125,7 @@ export default function OptionsAndPicture({
|
|||||||
setCropModalImageBlob={setCropModalImageBlob}
|
setCropModalImageBlob={setCropModalImageBlob}
|
||||||
onClose={closeCropModal}
|
onClose={closeCropModal}
|
||||||
onSaveImageClick={handleCropModalSaveClick}
|
onSaveImageClick={handleCropModalSaveClick}
|
||||||
|
questionId={question.id}
|
||||||
/>
|
/>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
|
@ -120,6 +120,7 @@ export default function OptionsPicture({
|
|||||||
setCropModalImageBlob={setCropModalImageBlob}
|
setCropModalImageBlob={setCropModalImageBlob}
|
||||||
onClose={closeCropModal}
|
onClose={closeCropModal}
|
||||||
onSaveImageClick={handleCropModalSaveClick}
|
onSaveImageClick={handleCropModalSaveClick}
|
||||||
|
questionId={question.id}
|
||||||
/>
|
/>
|
||||||
<Box sx={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
<Box sx={{ display: "flex", alignItems: "center", gap: "10px" }}>
|
||||||
<Link
|
<Link
|
||||||
|
@ -36,6 +36,7 @@ export default function QuestionsPage({
|
|||||||
updateEditSomeQuestion();
|
updateEditSomeQuestion();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
console.log("quiz", quiz)
|
||||||
if (!quiz) return null;
|
if (!quiz) return null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -44,6 +44,7 @@ export const createUntypedQuestion = (
|
|||||||
) =>
|
) =>
|
||||||
setProducedState(
|
setProducedState(
|
||||||
(state) => {
|
(state) => {
|
||||||
|
console.log("createUntypedQuestion", quizId)
|
||||||
const newUntypedQuestion = {
|
const newUntypedQuestion = {
|
||||||
id: nanoid(),
|
id: nanoid(),
|
||||||
quizId,
|
quizId,
|
||||||
@ -259,7 +260,6 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
|||||||
throw new Error(
|
throw new Error(
|
||||||
"Cannot update untyped question, use 'updateUntypedQuestion' instead",
|
"Cannot update untyped question, use 'updateUntypedQuestion' instead",
|
||||||
);
|
);
|
||||||
|
|
||||||
updateFn(question as T);
|
updateFn(question as T);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -278,7 +278,7 @@ export const updateQuestion = async <T = AnyTypedQuizQuestion>(
|
|||||||
if (!q) return;
|
if (!q) return;
|
||||||
if (q.type === null)
|
if (q.type === null)
|
||||||
throw new Error("Cannot send update request for untyped question");
|
throw new Error("Cannot send update request for untyped question");
|
||||||
|
console.log("отправляемый квешен", q)
|
||||||
try {
|
try {
|
||||||
const response = await questionApi.edit(
|
const response = await questionApi.edit(
|
||||||
questionToEditQuestionRequest(replaceEmptyLinesToSpace(q)),
|
questionToEditQuestionRequest(replaceEmptyLinesToSpace(q)),
|
||||||
@ -449,6 +449,8 @@ export const createTypedQuestion = async (
|
|||||||
requestQueue.enqueue(`createTypedQuestion-${questionId}`, async () => {
|
requestQueue.enqueue(`createTypedQuestion-${questionId}`, async () => {
|
||||||
const questions = useQuestionsStore.getState().questions;
|
const questions = useQuestionsStore.getState().questions;
|
||||||
const question = questions.find((q) => q.id === questionId);
|
const question = questions.find((q) => q.id === questionId);
|
||||||
|
console.log("createTypedQuestion", question)
|
||||||
|
console.log("createTypedQuestion", question?.quizId)
|
||||||
if (!question) return;
|
if (!question) return;
|
||||||
if (question.type !== null)
|
if (question.type !== null)
|
||||||
throw new Error("Cannot upgrade already typed question");
|
throw new Error("Cannot upgrade already typed question");
|
||||||
|
@ -132,6 +132,7 @@ export const MediaSelectionAndDisplay: FC<Iprops> = ({ resultData }) => {
|
|||||||
setCropModalImageBlob={setCropModalImageBlob}
|
setCropModalImageBlob={setCropModalImageBlob}
|
||||||
onClose={closeCropModal}
|
onClose={closeCropModal}
|
||||||
onSaveImageClick={handleCropModalSaveClick}
|
onSaveImageClick={handleCropModalSaveClick}
|
||||||
|
questionId={resultData.id}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
@ -23,6 +23,8 @@ import {
|
|||||||
getDarkenedAndResizedImageBlob,
|
getDarkenedAndResizedImageBlob,
|
||||||
getRotatedImageBlob,
|
getRotatedImageBlob,
|
||||||
} from "./utils/imageManipulation";
|
} from "./utils/imageManipulation";
|
||||||
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
|
import { deleteQuestion, updateQuestion } from "@root/questions/actions";
|
||||||
|
|
||||||
const styleSlider: SxProps<Theme> = {
|
const styleSlider: SxProps<Theme> = {
|
||||||
color: "#7E2AEA",
|
color: "#7E2AEA",
|
||||||
@ -55,6 +57,7 @@ interface Props {
|
|||||||
setCropModalImageBlob: (imageBlob: Blob) => void;
|
setCropModalImageBlob: (imageBlob: Blob) => void;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onSaveImageClick: (imageBlob: Blob) => void;
|
onSaveImageClick: (imageBlob: Blob) => void;
|
||||||
|
questionId?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CropModal: FC<Props> = ({
|
export const CropModal: FC<Props> = ({
|
||||||
@ -64,6 +67,7 @@ export const CropModal: FC<Props> = ({
|
|||||||
setCropModalImageBlob,
|
setCropModalImageBlob,
|
||||||
onSaveImageClick,
|
onSaveImageClick,
|
||||||
onClose,
|
onClose,
|
||||||
|
questionId
|
||||||
}) => {
|
}) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const [percentCrop, setPercentCrop] = useState<PercentCrop>();
|
const [percentCrop, setPercentCrop] = useState<PercentCrop>();
|
||||||
@ -263,7 +267,7 @@ export const CropModal: FC<Props> = ({
|
|||||||
sx={[
|
sx={[
|
||||||
styleSlider,
|
styleSlider,
|
||||||
{
|
{
|
||||||
width: isMobile ? undefined : "250px",
|
width: isMobile ? undefined : "200px",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={scale * 100}
|
value={scale * 100}
|
||||||
@ -283,7 +287,7 @@ export const CropModal: FC<Props> = ({
|
|||||||
sx={[
|
sx={[
|
||||||
styleSlider,
|
styleSlider,
|
||||||
{
|
{
|
||||||
width: isMobile ? undefined : "250px",
|
width: isMobile ? undefined : "200px",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
value={darken}
|
value={darken}
|
||||||
@ -293,6 +297,26 @@ export const CropModal: FC<Props> = ({
|
|||||||
onChange={(_, newValue) => setDarken(newValue as number)}
|
onChange={(_, newValue) => setDarken(newValue as number)}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
|
{questionId !== undefined &&
|
||||||
|
<IconButton
|
||||||
|
onClick={() => {
|
||||||
|
updateQuestion(questionId, (question) => {
|
||||||
|
question.content.back = null;
|
||||||
|
question.content.originalBack = null;
|
||||||
|
})
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
height: "48px",
|
||||||
|
width: "48px",
|
||||||
|
p: 0,
|
||||||
|
color: theme.palette.orange.main,
|
||||||
|
borderRadius: "50%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DeleteIcon />
|
||||||
|
</IconButton>
|
||||||
|
}
|
||||||
</Box>
|
</Box>
|
||||||
<Box
|
<Box
|
||||||
sx={{
|
sx={{
|
||||||
@ -327,9 +351,8 @@ export const CropModal: FC<Props> = ({
|
|||||||
background: theme.palette.brightPurple.main,
|
background: theme.palette.brightPurple.main,
|
||||||
fontSize: "18px",
|
fontSize: "18px",
|
||||||
color: "#7E2AEA",
|
color: "#7E2AEA",
|
||||||
border: `1px solid ${
|
border: `1px solid ${!completedCrop ? "rgba(0, 0, 0, 0.26)" : "#7E2AEA"
|
||||||
!completedCrop ? "rgba(0, 0, 0, 0.26)" : "#7E2AEA"
|
}`,
|
||||||
}`,
|
|
||||||
backgroundColor: "transparent",
|
backgroundColor: "transparent",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user