From ca653967fa267d27044ea560e4e195b0d5a8fa72 Mon Sep 17 00:00:00 2001 From: karimaldeen Date: Sat, 21 Sep 2024 15:39:59 +0300 Subject: [PATCH] fixx --- src/Components/LatextInput/AddLaTexModal.tsx | 4 +++- src/Components/LatextInput/LaTeXInputMemo.tsx | 20 ++++++++++++------- .../Model/Malty/ChoiceField/Choices.tsx | 3 --- src/Pages/Home/Dummy.tsx | 18 +---------------- 4 files changed, 17 insertions(+), 28 deletions(-) diff --git a/src/Components/LatextInput/AddLaTexModal.tsx b/src/Components/LatextInput/AddLaTexModal.tsx index ab0a7fd..b6df44d 100644 --- a/src/Components/LatextInput/AddLaTexModal.tsx +++ b/src/Components/LatextInput/AddLaTexModal.tsx @@ -6,12 +6,13 @@ import { convertMathMLToLaTeX } from '../../utils/convertMathMLToLaTeX'; import { useTranslation } from 'react-i18next'; import { toast } from 'react-toastify'; -const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ +const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen,setCurrentValue}:{ name:string, setLatex: (value:string)=> void, Latex:string, setIsModalOpen: (value:boolean)=> void , isModalOpen:boolean, + setCurrentValue:(value:string)=> void }) => { const {values,setFieldValue} = useFormikContext() @@ -27,6 +28,7 @@ const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen}:{ if(newLatex){ setFieldValue(name, oldValue + " $$ " +newLatex +" $$ "); + setCurrentValue(oldValue + " $$ " +newLatex +" $$ ") setLatex("") setIsModalOpen(false); }else{ diff --git a/src/Components/LatextInput/LaTeXInputMemo.tsx b/src/Components/LatextInput/LaTeXInputMemo.tsx index 22cae6a..7bcd3a2 100644 --- a/src/Components/LatextInput/LaTeXInputMemo.tsx +++ b/src/Components/LatextInput/LaTeXInputMemo.tsx @@ -1,6 +1,6 @@ import TextArea from 'antd/es/input/TextArea'; import { useFormikContext } from 'formik'; -import React, { Suspense, useState } from 'react'; +import React, { Suspense, useEffect, useState } from 'react'; import { parseTextAndLatex } from '../../utils/parseTextAndLatex'; import LatexPreview from '../CustomFields/MathComponent'; import { Checkbox } from 'antd'; @@ -20,7 +20,7 @@ const LaTeXInputMemo: React.FC = React.memo(({ field ,form, label, ...prop const { setFieldValue } = form; - const { ShowLatexOption } = useObjectToEdit(); + const { ShowLatexOption, Success } = useObjectToEdit(); const [showPreview, setShowPreview] = useState(false); const Preview = parseTextAndLatex(value ?? ""); @@ -39,9 +39,9 @@ const LaTeXInputMemo: React.FC = React.memo(({ field ,form, label, ...prop }; const handleEditModal = (item: any) => { - console.log(item); - setLatex(item); - setIsEditModalOpen(true); + // console.log(item); + // setLatex(item); + // setIsEditModalOpen(true); }; const [curCentValue, setCurrentValue] = useState(value) @@ -52,6 +52,12 @@ const LaTeXInputMemo: React.FC = React.memo(({ field ,form, label, ...prop setFieldValue(name, curCentValue); } + useEffect(() => { + if(Success){ + setCurrentValue(null) + } + }, [Success]) + return (
@@ -97,9 +103,9 @@ const LaTeXInputMemo: React.FC = React.memo(({ field ,form, label, ...prop )}
- }> - + + }> ); diff --git a/src/Pages/Admin/question/Model/Malty/ChoiceField/Choices.tsx b/src/Pages/Admin/question/Model/Malty/ChoiceField/Choices.tsx index a1d18ea..974c558 100644 --- a/src/Pages/Admin/question/Model/Malty/ChoiceField/Choices.tsx +++ b/src/Pages/Admin/question/Model/Malty/ChoiceField/Choices.tsx @@ -40,9 +40,6 @@ const Choices = React.memo( ({setFieldValue ,values,parent_index }:any) => { setFieldValue(`Questions.${parent_index}.answers`, updatedItems); }; - console.log(123); - console.log(setFieldValue); - console.log(values?.Questions?.[parent_index]); return ( <> diff --git a/src/Pages/Home/Dummy.tsx b/src/Pages/Home/Dummy.tsx index f6a55e1..17ab6aa 100644 --- a/src/Pages/Home/Dummy.tsx +++ b/src/Pages/Home/Dummy.tsx @@ -7,23 +7,7 @@ const Dummy = () => { return (
- {}}> -
- {Array.from({length:1000}).map((item:any,index)=>{ - return ( -
- - - -
- ) - })} -
-
+
);