fix header
This commit is contained in:
parent
4b9a4f4d23
commit
f5e0bebeb0
File diff suppressed because one or more lines are too long
|
|
@ -22,6 +22,9 @@ import { QUESTION_OBJECT_KEY } from "../../config/AppKey";
|
|||
import useSaveOnDisconnect from "../../Hooks/useSaveOnDisconnect";
|
||||
import { getLocalStorageQuestions } from "../../utils/setLocalStorageQuestions";
|
||||
import { toast } from "react-toastify";
|
||||
import useSetPage_title from "../../Hooks/useSetPageTitle";
|
||||
import { useGetAllUnit } from "../../api/unit";
|
||||
import { useGetAllLesson } from "../../api/lesson";
|
||||
|
||||
const AddPage: React.FC = () => {
|
||||
|
||||
|
|
@ -29,10 +32,33 @@ const AddPage: React.FC = () => {
|
|||
const { mutate,isSuccess, isLoading} = useAddQuestion();
|
||||
const {isBseQuestion,setTagsSearch,setObjectToEdit,setSuccess,SavedQuestionData} = useObjectToEdit()
|
||||
|
||||
const {subject_id,lesson_id} = useParams<ParamsEnum>()
|
||||
const {subject_id,lesson_id,unit_id} = useParams<ParamsEnum>()
|
||||
const { setIsOpen } = useModalState((state) => state);
|
||||
|
||||
|
||||
const { data: unit } = useGetAllUnit({ show: unit_id });
|
||||
const { data: lesson } = useGetAllLesson({ show: lesson_id });
|
||||
|
||||
const [t] = useTranslation()
|
||||
const unitName = unit?.data?.name ?? "";
|
||||
const SubjectName = unit?.data?.subject?.name ?? "";
|
||||
const lessonName = lesson?.data?.name ?? "";
|
||||
|
||||
useSetPage_title(
|
||||
t(`page_header.subject`) +
|
||||
"/" +
|
||||
`${SubjectName}` +
|
||||
"/" +
|
||||
t(`page_title.unit`) +
|
||||
"/" +
|
||||
`${unitName}`+"/"
|
||||
+
|
||||
t(`page_title.lesson`) +
|
||||
"/" +
|
||||
`${lessonName}`+ "/" +
|
||||
t(`page_title.questions`)
|
||||
);
|
||||
|
||||
|
||||
const handleSubmit = (values: any, { resetForm }: { resetForm: () => void }) => {
|
||||
const DataToSend = structuredClone(values);
|
||||
|
|
@ -117,7 +143,6 @@ const AddPage: React.FC = () => {
|
|||
}
|
||||
};
|
||||
|
||||
const [t] = useTranslation();
|
||||
|
||||
|
||||
if(isBseQuestion || SavedData?.isBase === 1){
|
||||
|
|
|
|||
|
|
@ -10,15 +10,17 @@ import { ParamsEnum } from "../../enums/params";
|
|||
import { useObjectToEdit } from "../../zustand/ObjectToEditState";
|
||||
import { removeStringKeys } from "../../utils/removeStringKeys";
|
||||
import SpinContainer from "../../Components/Layout/SpinContainer";
|
||||
import Header from "../../Components/exercise/Header";
|
||||
import Form from './Model/Edit'
|
||||
import BaseForm from './Model/Malty/Edit'
|
||||
import { Question } from "../../types/Item";
|
||||
import { toast } from "react-toastify";
|
||||
import useSetPage_title from "../../Hooks/useSetPageTitle";
|
||||
import { useGetAllUnit } from "../../api/unit";
|
||||
import { useGetAllLesson } from "../../api/lesson";
|
||||
|
||||
const EditPage: React.FC = () => {
|
||||
|
||||
const {question_id,subject_id} = useParams<ParamsEnum>()
|
||||
const {question_id,subject_id,unit_id} = useParams<ParamsEnum>()
|
||||
const {isBseQuestion,setIsBseQuestion,setTagsSearch,DeletedQuestions} = useObjectToEdit()
|
||||
|
||||
const { mutate, isSuccess, isLoading } = useUpdateQuestion();
|
||||
|
|
@ -40,6 +42,31 @@ const EditPage: React.FC = () => {
|
|||
}, [objectToEdit?.isBase])
|
||||
|
||||
|
||||
|
||||
const { data: unit } = useGetAllUnit({ show: unit_id });
|
||||
const { data: lesson } = useGetAllLesson({ show: lesson_id });
|
||||
|
||||
const [t] = useTranslation()
|
||||
const unitName = unit?.data?.name ?? "";
|
||||
const SubjectName = unit?.data?.subject?.name ?? "";
|
||||
const lessonName = lesson?.data?.name ?? "";
|
||||
|
||||
useSetPage_title(
|
||||
t(`page_header.subject`) +
|
||||
"/" +
|
||||
`${SubjectName}` +
|
||||
"/" +
|
||||
t(`page_title.unit`) +
|
||||
"/" +
|
||||
`${unitName}`+"/"
|
||||
+
|
||||
t(`page_title.lesson`) +
|
||||
"/" +
|
||||
`${lessonName}`+ "/" +
|
||||
t(`page_title.questions`)
|
||||
);
|
||||
|
||||
|
||||
const handleSubmit = (values: any) => {
|
||||
const DataToSend = structuredClone(values);
|
||||
setTagsSearch(null)
|
||||
|
|
@ -52,10 +79,11 @@ const EditPage: React.FC = () => {
|
|||
"content" : DataToSend?.content,
|
||||
"image": DataToSend?.image ?? "",
|
||||
}
|
||||
if( typeof UpdateBseQuestion?.image === "string"){
|
||||
if( typeof UpdateBseQuestion?.image === "string" && UpdateBseQuestion?.image !== ""){
|
||||
delete UpdateBseQuestion["image"]
|
||||
}
|
||||
console.log(DeletedQuestions,"DeletedQuestions");
|
||||
console.log(UpdateBseQuestion);
|
||||
|
||||
mutate(UpdateBseQuestion)
|
||||
|
||||
|
|
@ -118,11 +146,21 @@ const EditPage: React.FC = () => {
|
|||
delete updatedObject["parent_id"];
|
||||
const tags = processTags(updatedObject)
|
||||
console.log(updatedObject,"updatedObject");
|
||||
if(!(updatedObject?.image)){
|
||||
updatedObject["image"] = "" ;
|
||||
}
|
||||
console.log(updatedObject);
|
||||
|
||||
const oldQuestionOptions = [] as any;
|
||||
const newQuestionOptions = [] as any;
|
||||
|
||||
updatedObject?.QuestionOptions?.forEach((item:any) => {
|
||||
if (item?.id) {
|
||||
// if(!item?.answer_image){
|
||||
// item["answer_image"] = ""
|
||||
// }
|
||||
console.log(item);
|
||||
|
||||
oldQuestionOptions.push(item);
|
||||
} else {
|
||||
newQuestionOptions.push(item);
|
||||
|
|
@ -145,7 +183,6 @@ const EditPage: React.FC = () => {
|
|||
navigate(-1)
|
||||
};
|
||||
|
||||
const [t] = useTranslation();
|
||||
|
||||
useEffect(() => {
|
||||
if(isSuccess){
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user