+
-
+ {((formik?.values as any)?.Questions || [])?.map(
+ (item: Choice, parent_index: number) => {
+ return (
+
-
- {
- (((formik?.values as any)?.Questions)||[])?.map((item:Choice,parent_index:number)=>{
-
- return (
-
-
-
-
-
-
-
- {
- (((formik?.values as any)?.Questions?.[parent_index]?.QuestionOptions)||[]) .map((item:Choice,index:number)=>{
-
- return
- }
- )
- }
- {formik?.values?.Questions?.[parent_index]?.QuestionOptions?.length < 5 && (
-
- handleAddChoice(parent_index)} size={23} /> {t("header.add_new_choice")}
-
+ {(
+ (formik?.values as any)?.Questions?.[parent_index]
+ ?.QuestionOptions || []
+ ).map((item: Choice, index: number) => {
+ return (
+
+ );
+ })}
+ {formik?.values?.Questions?.[parent_index]?.QuestionOptions
+ ?.length < 5 && (
+
+ handleAddChoice(parent_index)}
+ size={23}
+ />{" "}
+ {t("header.add_new_choice")}
+
+ )}
+
+
+ );
+ },
)}
-
-
-
- )
- }
- )
- }
-
- {t("header.add_new_question")}
-
-
+
+ {" "}
+ {t("header.add_new_question")}
+
+
);
};
diff --git a/src/Pages/question/Model/Malty/QuestionFIeld/File.tsx b/src/Pages/question/Model/Malty/QuestionFIeld/File.tsx
index 457e1a5..cab227e 100644
--- a/src/Pages/question/Model/Malty/QuestionFIeld/File.tsx
+++ b/src/Pages/question/Model/Malty/QuestionFIeld/File.tsx
@@ -12,29 +12,28 @@ const File = ({
className,
props,
}: any) => {
+ const newName = `Questions[${name}].image`;
- const newName = `Questions[${name}].image`
-
- const { formik, t, isError,errorMsg } = useFormField(newName, props);
+ const { formik, t, isError, errorMsg } = useFormField(newName, props);
let imageUrl = formik?.values?.Questions?.[name]?.image ?? null;
// console.log(imageUrl);
-
+
const fileList: UploadFile[] = useMemo(() => {
if (!imageUrl) return [];
return [
- typeof imageUrl === 'string'
+ typeof imageUrl === "string"
? {
- uid: '-1',
- name: 'uploaded-image',
- status: 'done',
+ uid: "-1",
+ name: "uploaded-image",
+ status: "done",
url: imageUrl,
thumbUrl: imageUrl,
}
: {
- uid: imageUrl.uid || '-1',
- name: imageUrl.name || 'uploaded-image',
- status: 'done',
+ uid: imageUrl.uid || "-1",
+ name: imageUrl.name || "uploaded-image",
+ status: "done",
originFileObj: imageUrl,
},
];
@@ -46,8 +45,10 @@ const File = ({
if (value.fileList.length === 0) {
formik.setFieldValue(newName, null);
} else {
- formik.setFieldValue(`Questions[${name}].image`, value?.file?.originFileObj);
-
+ formik.setFieldValue(
+ `Questions[${name}].image`,
+ value?.file?.originFileObj,
+ );
}
};
const customRequest = async ({ onSuccess, no_label, label_icon }: any) => {
@@ -73,10 +74,9 @@ const File = ({
icon={
}
>
{placholder ?? t("input.Click_to_upload_the_image")}
-
{isError ? "required" : ""}
- {errorMsg}
+ {errorMsg}
);
diff --git a/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx b/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx
index 09862db..e1d4d77 100644
--- a/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx
+++ b/src/Pages/question/Model/Malty/QuestionFIeld/QuestionFIeld.tsx
@@ -1,47 +1,56 @@
-import React, { useEffect } from 'react'
-import { Choice } from '../../../../../types/Item'
-import ValidationField from '../../../../../Components/ValidationField/ValidationField'
-import { useFormikContext } from 'formik';
-import { useTranslation } from 'react-i18next';
-import { getCharFromNumber } from '../../../../../utils/getCharFromNumber';
-import TextField from './TextField';
-import File from './File';
-import { FaTrash } from 'react-icons/fa';
-import { useObjectToEdit } from '../../../../../zustand/ObjectToEditState';
-import { toast } from 'react-toastify';
+import React, { useEffect } from "react";
+import { Choice } from "../../../../../types/Item";
+import ValidationField from "../../../../../Components/ValidationField/ValidationField";
+import { useFormikContext } from "formik";
+import { useTranslation } from "react-i18next";
+import { getCharFromNumber } from "../../../../../utils/getCharFromNumber";
+import TextField from "./TextField";
+import File from "./File";
+import { FaTrash } from "react-icons/fa";
+import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
+import { toast } from "react-toastify";
-const QuestionFIeld = ({index,data}:{index:number , data :Choice }) => {
+const QuestionFIeld = ({ index, data }: { index: number; data: Choice }) => {
const formik = useFormikContext