From c1e2718e14aff326d31998a75ddf49ac4d23bded Mon Sep 17 00:00:00 2001 From: karimaldeen Date: Wed, 11 Sep 2024 17:02:49 +0300 Subject: [PATCH] remove curruclumn --- src/Pages/Admin/Unit/Page.tsx | 10 +- src/Pages/Admin/lesson/Page.tsx | 9 +- src/Pages/Admin/question/AddPage.tsx | 8 +- .../Admin/question/Model/AcceptModal.tsx | 5 +- src/Pages/Admin/question/Model/ModelForm.tsx | 2 - .../Admin/question/Model/Tags/DynamicTags.tsx | 91 ------------------- src/Pages/Admin/question/Model/Tags/Tag.tsx | 75 --------------- 7 files changed, 7 insertions(+), 193 deletions(-) delete mode 100644 src/Pages/Admin/question/Model/Tags/DynamicTags.tsx delete mode 100644 src/Pages/Admin/question/Model/Tags/Tag.tsx diff --git a/src/Pages/Admin/Unit/Page.tsx b/src/Pages/Admin/Unit/Page.tsx index 60d7aaf..7e65f94 100644 --- a/src/Pages/Admin/Unit/Page.tsx +++ b/src/Pages/Admin/Unit/Page.tsx @@ -8,7 +8,6 @@ import useSetPageTitle from "../../../Hooks/useSetPageTitle"; import { ModalEnum } from "../../../enums/Model"; import { useDeleteUnit } from "../../../api/unit"; import { useGetAllGrade } from "../../../api/grade"; -import { useGetAllCurriculum } from "../../../api/curriculum"; import PageHeader from "../../../Layout/Dashboard/PageHeader"; import FilterLayout from "../../../Layout/Dashboard/FilterLayout"; import FilterForm from "./Model/FilterForm"; @@ -34,13 +33,10 @@ const TableHeader = () => { const { data: grade } = useGetAllGrade({ show: grade_id, }); - const { data: Curriculum } = useGetAllCurriculum({ - show: curriculum_id, - }); + const gradeName = grade?.data?.name ?? ""; const SubjectName = Subject?.data?.name ?? ""; - const CurriculumName = Curriculum?.data?.name ?? ""; useSetPageTitle( t(`page_header.grade`) + "/" + @@ -50,10 +46,6 @@ const TableHeader = () => { "/" + SubjectName + "/" + - t("PageTitle.curriculum") + - "/" + - CurriculumName + - "/" + t("PageTitle.unit"), ); diff --git a/src/Pages/Admin/lesson/Page.tsx b/src/Pages/Admin/lesson/Page.tsx index d3c82b2..e84835e 100644 --- a/src/Pages/Admin/lesson/Page.tsx +++ b/src/Pages/Admin/lesson/Page.tsx @@ -36,13 +36,10 @@ const TableHeader = () => { const { data: grade } = useGetAllGrade({ show: grade_id, }); - const { data: Curriculum } = useGetAllCurriculum({ - show: curriculum_id, - }); + const gradeName = grade?.data?.name ?? ""; const SubjectName = Subject?.data?.name ?? ""; - const CurriculumName = Curriculum?.data?.name ?? ""; const unitName = unit?.data?.name ?? ""; useSetPageTitle( @@ -54,10 +51,6 @@ const TableHeader = () => { "/" + SubjectName + "/" + - t("PageTitle.curriculum") + - "/" + - CurriculumName + - "/" + t("PageTitle.unit") + "/" + unitName + diff --git a/src/Pages/Admin/question/AddPage.tsx b/src/Pages/Admin/question/AddPage.tsx index 9da576a..d4515e1 100644 --- a/src/Pages/Admin/question/AddPage.tsx +++ b/src/Pages/Admin/question/AddPage.tsx @@ -1,5 +1,5 @@ -import React, { Suspense, lazy, useEffect } from "react"; -import { Modal, Spin } from "antd"; +import React, { Suspense, lazy } from "react"; +import { Spin } from "antd"; import FormikForm from "../../../Layout/Dashboard/FormikFormModel"; import { getInitialValues, @@ -27,14 +27,12 @@ const AddPage: React.FC = () => { const { isBseQuestion, setTagsSearch, - setObjectToEdit, objectToEdit, } = useObjectToEdit(); - const { setIsOpen } = useModalState((state) => state); const [t] = useTranslation(); - const { unit_id, curriculum_id, grade_id, subject_id, lesson_id } = + const { subject_id, lesson_id } = useParams(); diff --git a/src/Pages/Admin/question/Model/AcceptModal.tsx b/src/Pages/Admin/question/Model/AcceptModal.tsx index fee6528..a73a490 100644 --- a/src/Pages/Admin/question/Model/AcceptModal.tsx +++ b/src/Pages/Admin/question/Model/AcceptModal.tsx @@ -1,10 +1,9 @@ -import React, { useEffect, useState } from "react"; -import { Input, Modal, Spin } from "antd"; +import React from "react"; +import { Modal } from "antd"; import { useModalState } from "../../../../zustand/Modal"; import { ModalEnum } from "../../../../enums/Model"; import { useTranslation } from "react-i18next"; import { useNavigate } from "react-router-dom"; -import { useObjectToEdit } from "../../../../zustand/ObjectToEditState"; import { QUESTION_OBJECT_KEY } from "../../../../config/AppKey"; const AcceptModal: React.FC = () => { diff --git a/src/Pages/Admin/question/Model/ModelForm.tsx b/src/Pages/Admin/question/Model/ModelForm.tsx index 0dd8518..5fcf7ee 100644 --- a/src/Pages/Admin/question/Model/ModelForm.tsx +++ b/src/Pages/Admin/question/Model/ModelForm.tsx @@ -1,11 +1,9 @@ import { Row } from "reactstrap"; import ValidationField from "../../../../Components/ValidationField/ValidationField"; import { useFormikContext } from "formik"; -import ChoiceFields from "./Field/ChoiceFields"; import { FaCirclePlus } from "react-icons/fa6"; import { Choice } from "../../../../types/Item"; import { useTranslation } from "react-i18next"; -import DynamicTags from "./Tags/DynamicTags"; import { useObjectToEdit } from "../../../../zustand/ObjectToEditState"; import { useEffect } from "react"; import Choices from "./Field/Choices"; diff --git a/src/Pages/Admin/question/Model/Tags/DynamicTags.tsx b/src/Pages/Admin/question/Model/Tags/DynamicTags.tsx deleted file mode 100644 index c1abc42..0000000 --- a/src/Pages/Admin/question/Model/Tags/DynamicTags.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { useFormikContext } from "formik"; -import React from "react"; -import { useTranslation } from "react-i18next"; -import { FaCirclePlus } from "react-icons/fa6"; -import Tag from "./Tag"; -import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState"; -import { useGetAllTag } from "../../../../../api/tags"; - -const DynamicTags = () => { - const formik = useFormikContext(); - const [t] = useTranslation(); - const { TagsSearch, setTagsSearch, currentTag } = useObjectToEdit(); - const { data } = useGetAllTag({ - name: TagsSearch, - }); - const suggests = data?.data; - - const handleAddChoice = () => { - const length = formik?.values?.tags.length; - const lastElement = formik?.values?.tags[length - 1]?.name; - setTagsSearch; - if (lastElement !== "") { - formik.setFieldValue("tags", [ - ...((formik?.values as any)?.tags as any[]), - - { - id: length + "_new", - name: "", - key: length, - }, - ]); - } else { - } - }; - // console.log(formik?.values); - // console.log(currentTag); - - const handleChoice = (item: any) => { - const length = formik.values.tags.length; - console.log(currentTag); - - formik.setFieldValue(`tags[${currentTag}]`, { ...item, key: length }); - setTagsSearch(null); - }; - - // console.log(formik?.values?.tags?.length); - - return ( -
- {formik?.values?.tags?.length < 1 && ( -

- {" "} - {t("header.add_tag")} -

- )} - -
-
- {(((formik?.values as any)?.tags as any[]) || []).map( - (item: any, index: number) => { - return ; - }, - )} -
- - {formik?.values?.tags?.length > 0 && ( -

- -

- )} -
- {TagsSearch && ( -
- {suggests?.map((item: any, index: number) => { - return ( -
handleChoice(item)} - > - {item?.name} -
- ); - })} -
- )} -
- ); -}; - -export default DynamicTags; diff --git a/src/Pages/Admin/question/Model/Tags/Tag.tsx b/src/Pages/Admin/question/Model/Tags/Tag.tsx deleted file mode 100644 index d9e34c6..0000000 --- a/src/Pages/Admin/question/Model/Tags/Tag.tsx +++ /dev/null @@ -1,75 +0,0 @@ -import { useFormikContext } from "formik"; -import React, { useRef, useEffect } from "react"; -import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState"; -import { FaTrash } from "react-icons/fa"; - -const Tag = ({ data, index }: { data: any; index: number }) => { - const inputRef = useRef(null); - const formik = useFormikContext(); - const { setTagsSearch, setCurrentTag } = useObjectToEdit(); - const timeoutRef = useRef(null); - const DEBOUNCE_DELAY = 500; - useEffect(() => { - if (inputRef.current) { - inputRef.current.style.width = `${(formik?.values?.tags[index]?.name?.length + 1) * 8}px`; - } - }, [formik?.values?.tags[index]?.name]); - - const handleEditInputChange = (e: React.ChangeEvent) => { - // console.log(e.target.value); - formik.setFieldValue(`tags[${index}].name`, e.target.value); - // setTagsSearch(e.target.value) - formik.setFieldValue(`tags.[${index}]`, { - key: index, - name: e.target.value, - id: `${index}_key`, - }); - - setCurrentTag(index); - if (timeoutRef.current) { - clearTimeout(timeoutRef.current); - } - - timeoutRef.current = setTimeout(() => { - setTagsSearch(e.target.value); - }, DEBOUNCE_DELAY); - }; - - const handleInputBlur = () => { - // setTagsSearch(null) - }; - - const handleDeleteChoice = () => { - console.log(data); - - // Create a copy of current tags array - const currentTags = [...formik.values.tags]; - - // Remove the item at the specified index from the array - currentTags.splice(index, 1); - - console.log(currentTags); // Log the updated tags array - - // Update formik field value with the updated tags array - formik.setFieldValue("tags", currentTags); - - // Reset search state if needed - setTagsSearch(null); - }; - - return ( -
- - -
- ); -}; - -export default Tag;