diff --git a/src/Pages/Admin/question/Model/Malty/Tags/MaltySelectTag.tsx b/src/Pages/Admin/question/Model/Malty/Tags/MaltySelectTag.tsx
index 584a085..1a4dfc0 100644
--- a/src/Pages/Admin/question/Model/Malty/Tags/MaltySelectTag.tsx
+++ b/src/Pages/Admin/question/Model/Malty/Tags/MaltySelectTag.tsx
@@ -36,11 +36,20 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
const [t] = useTranslation();
const options = data?.data ?? [];
- const additionalData =
- options?.length < 1 && searchValue.length > 1 && !isLoading
- ? [{ id: `new_${searchValue}`, name: searchValue }]
- : [];
+ const additionalData =
+ options.length < 1 && searchValue.length > 1 && !isLoading
+ ? [{ id: searchValue, name: searchValue }]
+ : [];
+
+ console.log(options);
+const value = formik?.values?.Questions[parent_index]?.tags?.map((item: any) => item?.id ?? item) ?? [];
+ console.log(formik?.values?.Questions[parent_index]);
+
+ console.log(value);
+
+ const AllOptions = [...options, ...additionalData]
+
return (
@@ -50,8 +59,9 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
style={{ width: "100%", height: "40px" }}
placeholder=""
fieldNames={{ label: "name", value: "id" }}
+
onChange={handleChange}
- options={[...options, ...additionalData]}
+ options={AllOptions}
filterOption={false}
loading={isLoading}
notFoundContent={isLoading ? : t("practical.not_found")}
@@ -65,7 +75,7 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
handleBlur();
}
}}
- value={values ?? []}
+ value={value}
/>
);
diff --git a/src/Pages/Admin/question/Model/formUtil.ts b/src/Pages/Admin/question/Model/formUtil.ts
index 39b85fa..2a2fdaa 100644
--- a/src/Pages/Admin/question/Model/formUtil.ts
+++ b/src/Pages/Admin/question/Model/formUtil.ts
@@ -5,10 +5,10 @@ import { QUESTION_OBJECT_KEY } from "../../../../config/AppKey";
export const getInitialValues = (objectToEdit: Question): any => {
const tags = objectToEdit?.tags?.map((item: any, index: number) => {
- return { ...item, key: index };
+ return { ...item };
});
- console.log(objectToEdit);
-
+ console.log(tags);
+
return {
id: objectToEdit?.id ?? null,
content: objectToEdit?.content ?? "",
@@ -45,13 +45,14 @@ export const getInitialValuesBase = (objectToEdit: Question): any => {
const tags = item?.tags?.map((tag: any) => ({
id: tag?.id,
name: tag?.name,
- key: `${tag?.id}_key_${tag?.name}`,
}));
-
+ console.log(tags);
+
return {
...item,
canAnswersBeShuffled: objectToEdit?.canAnswersBeShuffled ? 1 : 0,
- hint: item?.hint ?? "",
+ hint: objectToEdit?.hint ?? "",
+ isBase:0,
tags,
};
});
diff --git a/src/Pages/Admin/question/Page.tsx b/src/Pages/Admin/question/Page.tsx
index d4fe210..79245e3 100644
--- a/src/Pages/Admin/question/Page.tsx
+++ b/src/Pages/Admin/question/Page.tsx
@@ -24,7 +24,7 @@ const TableHeader = () => {
const deleteMutation = useDeleteQuestion();
- const { unit_id, curriculum_id, grade_id, subject_id, lesson_id } =
+ const { unit_id, grade_id, subject_id, lesson_id } =
useParams
();
const { data: unit } = useGetAllUnit({ show: unit_id });
@@ -34,16 +34,13 @@ const TableHeader = () => {
const { data: grade } = useGetAllGrade({
show: grade_id,
});
- const { data: Curriculum } = useGetAllCurriculum({
- show: curriculum_id,
- });
+
const { data: Lesson } = useGetAllLesson({
show: lesson_id,
});
const gradeName = grade?.data?.name ?? "";
const SubjectName = Subject?.data?.name ?? "";
- const CurriculumName = Curriculum?.data?.name ?? "";
const unitName = unit?.data?.name ?? "";
const LessonName = Lesson?.data?.name ?? "";
@@ -56,10 +53,6 @@ const TableHeader = () => {
"/" +
SubjectName +
"/" +
- t("PageTitle.curriculum") +
- "/" +
- CurriculumName +
- "/" +
t("PageTitle.unit") +
"/" +
unitName +
diff --git a/src/utils/removeStringKeys.ts b/src/utils/removeStringKeys.ts
index 85f55ab..c433b15 100644
--- a/src/utils/removeStringKeys.ts
+++ b/src/utils/removeStringKeys.ts
@@ -1,11 +1,23 @@
export function removeStringKeys(obj: any, keysToRemove: string[]): any {
- if (typeof obj === "object" && obj !== null) {
- for (const key in obj) {
- if (obj.hasOwnProperty(key)) {
- if (keysToRemove.includes(key) && typeof obj[key] === "string") {
- delete obj[key];
- } else {
- removeStringKeys(obj[key], keysToRemove);
+ // Check if the input is an object or array
+ if (obj && typeof obj === 'object') {
+ // Handle arrays
+ if (Array.isArray(obj)) {
+ obj.forEach((item, index) => {
+ obj[index] = removeStringKeys(item, keysToRemove);
+ });
+ } else {
+ // Handle objects
+ for (const key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ const value = obj[key];
+ // Check if the value is a string or "null" and the key is in keysToRemove
+ if (keysToRemove.includes(key) && (typeof value === 'string' || value === 'null')) {
+ delete obj[key];
+ } else {
+ // Recursively process nested objects or arrays
+ obj[key] = removeStringKeys(value, keysToRemove);
+ }
}
}
}