From e41dc330bd736b9c8ed77f78d0561e9a86dfbb99 Mon Sep 17 00:00:00 2001 From: Nastya Date: Thu, 28 Mar 2024 01:35:54 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=B1=D0=B5=D0=B7=D1=82=D0=B8=D0=BF?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=B3=D0=BE=20=D0=B2=D0=BE=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D0=B0=20=D0=B2=20=D1=81=D0=BF=D0=B8=D1=81=D0=BA=D0=B5=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=8E=D0=B7=D1=8D=D1=84=D1=84=D0=B5=D0=BA=D1=82?= =?UTF-8?q?=20=D0=B8=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D1=8C=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F=20=D0=BA=D0=B0=D1=80=D1=82=D0=B8=D0=BD=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B7=20=D1=80=D0=B5=D0=B7=D1=83=D0=BB=D1=8C=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Questions/DraggableList/index.tsx | 4 ++- .../OptionsAndPicture/OptionsAndPicture.tsx | 1 + .../OptionsPicture/OptionsPicture.tsx | 1 + src/pages/Questions/QuestionsPage.tsx | 1 + src/stores/questions/actions.ts | 6 ++-- src/ui_kit/MediaSelectionAndDisplay.tsx | 1 + src/ui_kit/Modal/CropModal.tsx | 33 ++++++++++++++++--- 7 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/pages/Questions/DraggableList/index.tsx b/src/pages/Questions/DraggableList/index.tsx index 6d596b12..02a1a105 100644 --- a/src/pages/Questions/DraggableList/index.tsx +++ b/src/pages/Questions/DraggableList/index.tsx @@ -28,7 +28,9 @@ export const DraggableList = ({ useEffect(() => { if (!isLoading && quiz && !filteredQuestions.length) { - createUntypedQuestion(Number(quiz.id)); + console.log("useEffect", quiz) + console.log(Number(quiz.backendId)) + createUntypedQuestion(Number(quiz.backendId)); } }, [quiz, filteredQuestions]); diff --git a/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx b/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx index 3191e07f..f656a017 100644 --- a/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx +++ b/src/pages/Questions/OptionsAndPicture/OptionsAndPicture.tsx @@ -125,6 +125,7 @@ export default function OptionsAndPicture({ setCropModalImageBlob={setCropModalImageBlob} onClose={closeCropModal} onSaveImageClick={handleCropModalSaveClick} + questionId={question.id} /> setProducedState( (state) => { + console.log("createUntypedQuestion", quizId) const newUntypedQuestion = { id: nanoid(), quizId, @@ -259,7 +260,6 @@ export const updateQuestion = async ( throw new Error( "Cannot update untyped question, use 'updateUntypedQuestion' instead", ); - updateFn(question as T); }, { @@ -278,7 +278,7 @@ export const updateQuestion = async ( if (!q) return; if (q.type === null) throw new Error("Cannot send update request for untyped question"); - +console.log("отправляемый квешен", q) try { const response = await questionApi.edit( questionToEditQuestionRequest(replaceEmptyLinesToSpace(q)), @@ -449,6 +449,8 @@ export const createTypedQuestion = async ( requestQueue.enqueue(`createTypedQuestion-${questionId}`, async () => { const questions = useQuestionsStore.getState().questions; const question = questions.find((q) => q.id === questionId); + console.log("createTypedQuestion", question) + console.log("createTypedQuestion", question?.quizId) if (!question) return; if (question.type !== null) throw new Error("Cannot upgrade already typed question"); diff --git a/src/ui_kit/MediaSelectionAndDisplay.tsx b/src/ui_kit/MediaSelectionAndDisplay.tsx index 33484b53..511d3111 100644 --- a/src/ui_kit/MediaSelectionAndDisplay.tsx +++ b/src/ui_kit/MediaSelectionAndDisplay.tsx @@ -132,6 +132,7 @@ export const MediaSelectionAndDisplay: FC = ({ resultData }) => { setCropModalImageBlob={setCropModalImageBlob} onClose={closeCropModal} onSaveImageClick={handleCropModalSaveClick} + questionId={resultData.id} /> diff --git a/src/ui_kit/Modal/CropModal.tsx b/src/ui_kit/Modal/CropModal.tsx index 6cd83832..b76b296e 100644 --- a/src/ui_kit/Modal/CropModal.tsx +++ b/src/ui_kit/Modal/CropModal.tsx @@ -23,6 +23,8 @@ import { getDarkenedAndResizedImageBlob, getRotatedImageBlob, } from "./utils/imageManipulation"; +import DeleteIcon from "@mui/icons-material/Delete"; +import { deleteQuestion, updateQuestion } from "@root/questions/actions"; const styleSlider: SxProps = { color: "#7E2AEA", @@ -55,6 +57,7 @@ interface Props { setCropModalImageBlob: (imageBlob: Blob) => void; onClose: () => void; onSaveImageClick: (imageBlob: Blob) => void; + questionId?: string; } export const CropModal: FC = ({ @@ -64,6 +67,7 @@ export const CropModal: FC = ({ setCropModalImageBlob, onSaveImageClick, onClose, + questionId }) => { const theme = useTheme(); const [percentCrop, setPercentCrop] = useState(); @@ -263,7 +267,7 @@ export const CropModal: FC = ({ sx={[ styleSlider, { - width: isMobile ? undefined : "250px", + width: isMobile ? undefined : "200px", }, ]} value={scale * 100} @@ -283,7 +287,7 @@ export const CropModal: FC = ({ sx={[ styleSlider, { - width: isMobile ? undefined : "250px", + width: isMobile ? undefined : "200px", }, ]} value={darken} @@ -293,6 +297,26 @@ export const CropModal: FC = ({ onChange={(_, newValue) => setDarken(newValue as number)} /> + {questionId !== undefined && + { + 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%", + }} + > + + + } = ({ background: theme.palette.brightPurple.main, fontSize: "18px", color: "#7E2AEA", - border: `1px solid ${ - !completedCrop ? "rgba(0, 0, 0, 0.26)" : "#7E2AEA" - }`, + border: `1px solid ${!completedCrop ? "rgba(0, 0, 0, 0.26)" : "#7E2AEA" + }`, backgroundColor: "transparent", }} >