From 2915d85fcfb29ef808cce2d01b401c844a7fbb73 Mon Sep 17 00:00:00 2001 From: karimaldeen Date: Sat, 17 Aug 2024 11:47:16 +0300 Subject: [PATCH] fix hint --- .../Model/Malty/ChoiceField/ChoiceFields.tsx | 14 +++++ .../Model/Malty/ChoiceField/HintField.tsx | 54 +++++++++++++++++++ .../Model/Malty/QuestionFIeld/HintField.tsx | 52 ++++++++++++++++++ .../Malty/QuestionFIeld/QuestionFIeld.tsx | 11 +++- src/Styles/Pages/Classes.scss | 7 +++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 src/Pages/question/Model/Malty/ChoiceField/HintField.tsx create mode 100644 src/Pages/question/Model/Malty/QuestionFIeld/HintField.tsx diff --git a/src/Pages/question/Model/Malty/ChoiceField/ChoiceFields.tsx b/src/Pages/question/Model/Malty/ChoiceField/ChoiceFields.tsx index 0f88532..13bb225 100644 --- a/src/Pages/question/Model/Malty/ChoiceField/ChoiceFields.tsx +++ b/src/Pages/question/Model/Malty/ChoiceField/ChoiceFields.tsx @@ -9,6 +9,7 @@ import TextField from "./TextField"; import File from "./File"; import { FaTrash } from "react-icons/fa"; import { toast } from "react-toastify"; +import HintField from "./HintField"; const ChoiceFields = ({ index, @@ -45,6 +46,7 @@ const ChoiceFields = ({ ); }; return ( + <>

+
+ +
+ ); }; diff --git a/src/Pages/question/Model/Malty/ChoiceField/HintField.tsx b/src/Pages/question/Model/Malty/ChoiceField/HintField.tsx new file mode 100644 index 0000000..dc93761 --- /dev/null +++ b/src/Pages/question/Model/Malty/ChoiceField/HintField.tsx @@ -0,0 +1,54 @@ +import { Form, Input } from "antd"; +import React from "react"; +import useFormField from "../../../../../Hooks/useFormField"; +import { MdOutlineEdit } from "react-icons/md"; +import { Field } from "formik"; + +const HintField = ({ + name, + label, + label2, + placeholder, + isDisabled, + onChange, + props, + parent_index, + id, + className, +}: any) => { + const newName = `Questions[${parent_index}].QuestionOptions[${name}].hint`; + + const { formik, isError, errorMsg, t } = useFormField(newName, props); + const TextFilehandleChange = ( + e: React.ChangeEvent, + ) => { + // console.log('Change:', e.target.value); + formik.setFieldValue(newName, e.target.value); + }; + + return ( +
+ + + + +
+ ); +}; + +export default React.memo(HintField); diff --git a/src/Pages/question/Model/Malty/QuestionFIeld/HintField.tsx b/src/Pages/question/Model/Malty/QuestionFIeld/HintField.tsx new file mode 100644 index 0000000..4baf9b1 --- /dev/null +++ b/src/Pages/question/Model/Malty/QuestionFIeld/HintField.tsx @@ -0,0 +1,52 @@ +import { Form, Input } from "antd"; +import React from "react"; +import useFormField from "../../../../../Hooks/useFormField"; +import { MdOutlineEdit } from "react-icons/md"; +import { Field } from "formik"; + +const HintField = ({ + name, + label, + label2, + placeholder, + isDisabled, + onChange, + props, + id, + className, +}: any) => { + const newName = `Questions[${name}].hint`; + const { formik, isError, errorMsg, t } = useFormField(newName, props); + const TextFilehandleChange = ( + e: React.ChangeEvent, + ) => { + // console.log('Change:', e.target.value); + formik.setFieldValue(newName, e.target.value); + }; + + return ( +
+ + + + +
+ ); +}; + +export default React.memo(HintField); diff --git a/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx b/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx index 9f1568d..ba68cd9 100644 --- a/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx +++ b/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx @@ -10,10 +10,10 @@ import { FaTrash } from "react-icons/fa"; import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState"; import { toast } from "react-toastify"; import CheckboxField from "./CheckboxField"; +import HintField from "./HintField"; const QuestionFIeld = ({ index, data }: { index: number; data: Choice }) => { const formik = useFormikContext(); - console.log(index); const { setDeletedQuestions, DeletedQuestions } = useObjectToEdit(); const [t] = useTranslation(); @@ -33,6 +33,7 @@ const QuestionFIeld = ({ index, data }: { index: number; data: Choice }) => { }; return ( +
{ label={"canAnswersBeShuffled"} name={index} /> + +

+ +
+ +
+ +
); }; diff --git a/src/Styles/Pages/Classes.scss b/src/Styles/Pages/Classes.scss index 3ba38b9..588e7fd 100644 --- a/src/Styles/Pages/Classes.scss +++ b/src/Styles/Pages/Classes.scss @@ -92,3 +92,10 @@ .ant-upload-wrapper { width: 100%; } + + +.d-c{ + display: flex; + flex-direction: column; + flex: 1; +} \ No newline at end of file