Merge branch 'dev' of https://git.point-dev.net/Karimaldeen/Quiz_dashboard into dev
This commit is contained in:
commit
553d749633
|
|
@ -8,7 +8,6 @@ import {
|
|||
} from "@ant-design/icons";
|
||||
import React from "react";
|
||||
import { Image, Space } from "antd";
|
||||
import { ImageBaseURL } from "../../api/config";
|
||||
import useImageError from "../../Hooks/useImageError";
|
||||
import { ErrorImage } from "../../Layout/app/Const";
|
||||
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ const ImageBoxField = ({ name }: any) => {
|
|||
const value = getNestedValue(formik.values, name);
|
||||
const [imagePreview, setImagePreview] = useState<string | null>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null);
|
||||
console.log(formik.values);
|
||||
|
||||
console.log(value, name);
|
||||
|
||||
useEffect(() => {
|
||||
if (value instanceof File) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import { Button, Image, Upload, UploadFile } from "antd";
|
||||
import useFormField from "../../Hooks/useFormField";
|
||||
import { UploadOutlined } from "@ant-design/icons";
|
||||
import { ImageBaseURL } from "../../api/config";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FaRegFilePdf } from "react-icons/fa";
|
||||
import { useState } from "react";
|
||||
|
|
@ -17,7 +16,7 @@ const PdfUploader = ({
|
|||
}: any) => {
|
||||
const { formik, t, isError } = useFormField(name, props);
|
||||
let FormikName = formik.values[name];
|
||||
const imageUrl = formik.values[name] ? ImageBaseURL + FormikName : "";
|
||||
const imageUrl = formik.values[name] ? FormikName : "";
|
||||
const [Imageurl, setImageurl] = useState(null);
|
||||
|
||||
const FilehandleChange = (value: any) => {
|
||||
|
|
|
|||
|
|
@ -37,11 +37,20 @@ const SelectTag: React.FC = () => {
|
|||
const [t] = useTranslation();
|
||||
|
||||
const options = data?.data ?? [];
|
||||
const additionalData =
|
||||
options?.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: `${searchValue}`, name: searchValue }]
|
||||
: [];
|
||||
const additionalData =
|
||||
options.length < 1 && searchValue.length > 1 && !isLoading
|
||||
? [{ id: searchValue, name: searchValue }]
|
||||
: [];
|
||||
|
||||
|
||||
console.log(options);
|
||||
console.log(formik?.values?.tags);
|
||||
const value = formik?.values?.tags?.map((item: any) => item?.id ?? item) ?? [];
|
||||
|
||||
|
||||
const AllOptions = [...options, ...additionalData]
|
||||
console.log(AllOptions);
|
||||
|
||||
return (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
@ -52,7 +61,7 @@ const SelectTag: React.FC = () => {
|
|||
placeholder=""
|
||||
fieldNames={{ label: "name", value: "id" }}
|
||||
onChange={handleChange}
|
||||
options={[...options, ...additionalData]}
|
||||
options={AllOptions}
|
||||
filterOption={false}
|
||||
loading={isLoading}
|
||||
notFoundContent={isLoading ? <Spin /> : t("practical.not_found")}
|
||||
|
|
@ -66,7 +75,7 @@ const SelectTag: React.FC = () => {
|
|||
handleBlur();
|
||||
}
|
||||
}}
|
||||
value={formik?.values?.tags ?? []}
|
||||
value={value}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
30
src/Components/FilterField/components/useFilter.tsx
Normal file
30
src/Components/FilterField/components/useFilter.tsx
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import React from 'react'
|
||||
|
||||
|
||||
|
||||
interface IFilterBody {
|
||||
children:React.ReactNode
|
||||
}
|
||||
const useFilter = () => {
|
||||
|
||||
const FilterButton = ()=>{
|
||||
return (
|
||||
<div>
|
||||
FilterButton
|
||||
</div>
|
||||
)
|
||||
}
|
||||
const FilterBody = ({children}:IFilterBody)=>{
|
||||
return (
|
||||
<div>
|
||||
FilterBody
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return {
|
||||
FilterButton , FilterBody
|
||||
}
|
||||
}
|
||||
|
||||
export default useFilter
|
||||
5
src/Components/FilterField/enums/Filter.ts
Normal file
5
src/Components/FilterField/enums/Filter.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
export enum FilterEnum {
|
||||
FILTER="FILTER"
|
||||
|
||||
|
||||
}
|
||||
22
src/Components/FilterField/states/FilterState.ts
Normal file
22
src/Components/FilterField/states/FilterState.ts
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
import { create } from "zustand";
|
||||
|
||||
interface FilterState {
|
||||
filterState: any[];
|
||||
setFilterState: (data: any) => void;
|
||||
clearFilterState: () => void;
|
||||
setWithOldValue: (data: any) => void;
|
||||
setInitialValue: (data: any) => void;
|
||||
}
|
||||
|
||||
export const useFilterState = create<FilterState>((set, get) => ({
|
||||
filterState: [],
|
||||
setFilterState: (data) => set(() => ({ filterState: data })),
|
||||
clearFilterState: () => set(() => ({ filterState: [] })),
|
||||
setWithOldValue: (data) =>
|
||||
set((state) => ({ filterState: [...state.filterState, data] })),
|
||||
setInitialValue: (data) => {
|
||||
if (get().filterState.length < 1) {
|
||||
set(() => ({ filterState: data }));
|
||||
}
|
||||
},
|
||||
}));
|
||||
32
src/Hooks/useKeyCombination.tsx
Normal file
32
src/Hooks/useKeyCombination.tsx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { useEffect } from 'react';
|
||||
|
||||
type KeyCombination = {
|
||||
ctrlKey?: boolean;
|
||||
shiftKey?: boolean;
|
||||
code: string; // Use string here for flexibility
|
||||
};
|
||||
|
||||
const useKeyCombination = (keyCombination: KeyCombination, callback: () => void) => {
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: KeyboardEvent) => {
|
||||
const matches =
|
||||
(keyCombination.ctrlKey === undefined || event.ctrlKey === keyCombination.ctrlKey) &&
|
||||
(keyCombination.shiftKey === undefined || event.shiftKey === keyCombination.shiftKey) &&
|
||||
event.code === keyCombination.code;
|
||||
|
||||
if (matches) {
|
||||
callback();
|
||||
event.preventDefault(); // Prevent the default action for the event
|
||||
event.stopPropagation(); // Stop the event from propagating further
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener('keydown', handleKeyDown);
|
||||
|
||||
return () => {
|
||||
window.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [keyCombination, callback]);
|
||||
};
|
||||
|
||||
export default useKeyCombination;
|
||||
|
|
@ -21,20 +21,6 @@ import ModelForm from "./Model/ModelForm";
|
|||
const AcceptModal = lazy(() => import("./Model/AcceptModal"));
|
||||
|
||||
import { useModalState } from "../../../zustand/Modal";
|
||||
import { ModalEnum } from "../../../enums/Model";
|
||||
import { cleanObject } from "../../../utils/cleanObject";
|
||||
import { hasItems } from "../../../utils/hasItems";
|
||||
import { QUESTION_OBJECT_KEY } from "../../../config/AppKey";
|
||||
import useSaveOnDisconnect from "../../../Hooks/useSaveOnDisconnect";
|
||||
import { getLocalStorageQuestions } from "../../../utils/setLocalStorageQuestions";
|
||||
import { toast } from "react-toastify";
|
||||
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
|
||||
import { useGetAllUnit } from "../../../api/unit";
|
||||
import { useGetAllLesson } from "../../../api/lesson";
|
||||
import { useGetAllSubject } from "../../../api/subject";
|
||||
import { useGetAllGrade } from "../../../api/grade";
|
||||
import { useGetAllCurriculum } from "../../../api/curriculum";
|
||||
|
||||
const AddPage: React.FC = () => {
|
||||
const { isSuccess: isSuccessAsync, mutateAsync } = useAddQuestionAsync();
|
||||
const { mutate, isSuccess, isLoading } = useAddQuestion();
|
||||
|
|
@ -43,8 +29,6 @@ const AddPage: React.FC = () => {
|
|||
setTagsSearch,
|
||||
setObjectToEdit,
|
||||
objectToEdit,
|
||||
setSuccess,
|
||||
SavedQuestionData,
|
||||
} = useObjectToEdit();
|
||||
|
||||
const { setIsOpen } = useModalState((state) => state);
|
||||
|
|
@ -52,52 +36,8 @@ const AddPage: React.FC = () => {
|
|||
const [t] = useTranslation();
|
||||
const { unit_id, curriculum_id, grade_id, subject_id, lesson_id } =
|
||||
useParams<ParamsEnum>();
|
||||
const { data: unit } = useGetAllUnit({ show: unit_id });
|
||||
|
||||
|
||||
const { data: Subject } = useGetAllSubject({
|
||||
show: subject_id,
|
||||
});
|
||||
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 ?? "";
|
||||
|
||||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
"/" +
|
||||
gradeName +
|
||||
"/" +
|
||||
t(`PageTitle.subject`) +
|
||||
"/" +
|
||||
SubjectName +
|
||||
"/" +
|
||||
t("PageTitle.curriculum") +
|
||||
"/" +
|
||||
CurriculumName +
|
||||
"/" +
|
||||
t("PageTitle.unit") +
|
||||
"/" +
|
||||
unitName +
|
||||
"/" +
|
||||
t("PageTitle.lesson") +
|
||||
"/" +
|
||||
LessonName +
|
||||
"/" +
|
||||
t("PageTitle.question") +
|
||||
"/" +
|
||||
t("practical.add"),
|
||||
);
|
||||
|
||||
const handleSubmit = (
|
||||
values: any,
|
||||
|
|
@ -206,6 +146,9 @@ const AddPage: React.FC = () => {
|
|||
// }
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
if (isBseQuestion) {
|
||||
return (
|
||||
<div className="exercise_add">
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import {
|
|||
useGetAllQuestion,
|
||||
useUpdateQuestion,
|
||||
} from "../../../api/Question";
|
||||
import { useQueryClient } from "react-query";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useNavigate, useParams } from "react-router-dom";
|
||||
import { ParamsEnum } from "../../../enums/params";
|
||||
|
|
@ -25,18 +24,10 @@ import ModelForm from "./Model/ModelForm";
|
|||
import BaseForm from "./Model/Malty/Form";
|
||||
import { Question } from "../../../types/Item";
|
||||
import { toast } from "react-toastify";
|
||||
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
|
||||
import { useGetAllUnit } from "../../../api/unit";
|
||||
import { useGetAllLesson } from "../../../api/lesson";
|
||||
import { useGetAllSubject } from "../../../api/subject";
|
||||
import { useGetAllGrade } from "../../../api/grade";
|
||||
import { useGetAllCurriculum } from "../../../api/curriculum";
|
||||
|
||||
|
||||
const EditPage: React.FC = () => {
|
||||
const {
|
||||
unit_id,
|
||||
curriculum_id,
|
||||
grade_id,
|
||||
subject_id,
|
||||
lesson_id,
|
||||
question_id,
|
||||
|
|
@ -54,8 +45,7 @@ const EditPage: React.FC = () => {
|
|||
|
||||
const { data: Questions, isLoading: QuestionsDataLoading } =
|
||||
useGetAllQuestion({
|
||||
questionParentId: question_id,
|
||||
onlyWithNoParents: false,
|
||||
parent_id: question_id,
|
||||
});
|
||||
|
||||
const objectToEdit = { ...data?.data, Questions: Questions?.data };
|
||||
|
|
@ -67,52 +57,8 @@ const EditPage: React.FC = () => {
|
|||
}, [objectToEdit?.isBase]);
|
||||
|
||||
const [t] = useTranslation();
|
||||
const { data: unit } = useGetAllUnit({ show: unit_id });
|
||||
|
||||
const { data: Subject } = useGetAllSubject({
|
||||
show: subject_id,
|
||||
});
|
||||
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 ?? "";
|
||||
|
||||
useSetPageTitle(
|
||||
t(`page_header.grade`) +
|
||||
"/" +
|
||||
gradeName +
|
||||
"/" +
|
||||
t(`PageTitle.subject`) +
|
||||
"/" +
|
||||
SubjectName +
|
||||
"/" +
|
||||
t("PageTitle.curriculum") +
|
||||
"/" +
|
||||
CurriculumName +
|
||||
"/" +
|
||||
t("PageTitle.unit") +
|
||||
"/" +
|
||||
unitName +
|
||||
"/" +
|
||||
t("PageTitle.lesson") +
|
||||
"/" +
|
||||
LessonName +
|
||||
"/" +
|
||||
t("PageTitle.question") +
|
||||
"/" +
|
||||
t("practical.edit"),
|
||||
);
|
||||
|
||||
const handleSubmit = (values: any) => {
|
||||
const DataToSend = structuredClone(values);
|
||||
|
|
@ -123,13 +69,13 @@ const EditPage: React.FC = () => {
|
|||
const UpdateBseQuestion = {
|
||||
id: DataToSend?.id,
|
||||
content: DataToSend?.content,
|
||||
image: DataToSend?.image ?? "",
|
||||
content_image: DataToSend?.content_image ?? "",
|
||||
};
|
||||
if (
|
||||
typeof UpdateBseQuestion?.image === "string" &&
|
||||
UpdateBseQuestion?.image !== ""
|
||||
typeof UpdateBseQuestion?.content_image === "string" &&
|
||||
UpdateBseQuestion?.content_image !== ""
|
||||
) {
|
||||
delete UpdateBseQuestion["image"];
|
||||
delete UpdateBseQuestion["content_image"];
|
||||
}
|
||||
console.log(DeletedQuestions, "DeletedQuestions");
|
||||
console.log(UpdateBseQuestion);
|
||||
|
|
@ -147,24 +93,24 @@ const EditPage: React.FC = () => {
|
|||
console.log(item);
|
||||
if (item?.id) {
|
||||
const itemToSend = structuredClone(item);
|
||||
const keysToRemove = ["image", "answer_image"];
|
||||
const keysToRemove = ["content_image"];
|
||||
const updatedObject = removeStringKeys(itemToSend, keysToRemove);
|
||||
console.log(updatedObject, "updatedObject");
|
||||
|
||||
const tags = processTags(updatedObject);
|
||||
const oldanswers = [] as any;
|
||||
const newanswers = [] as any;
|
||||
const oldAnswers = [] as any;
|
||||
const newAnswers = [] as any;
|
||||
|
||||
updatedObject?.answers?.forEach((item: any) => {
|
||||
if (item?.id) {
|
||||
oldanswers.push(item);
|
||||
oldAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
} else {
|
||||
newanswers.push(item);
|
||||
newAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
}
|
||||
});
|
||||
const answers = {
|
||||
old: oldanswers,
|
||||
new: newanswers,
|
||||
old: oldAnswers,
|
||||
new: newAnswers,
|
||||
};
|
||||
console.log(answers);
|
||||
|
||||
|
|
@ -187,34 +133,31 @@ const EditPage: React.FC = () => {
|
|||
}
|
||||
});
|
||||
} else {
|
||||
const keysToRemove = ["image", "answer_image"];
|
||||
|
||||
const keysToRemove = ["content_image"];
|
||||
console.log(DataToSend);
|
||||
const updatedObject = removeStringKeys(DataToSend, keysToRemove);
|
||||
delete updatedObject["parent_id"];
|
||||
const tags = processTags(updatedObject);
|
||||
console.log(updatedObject, "updatedObject");
|
||||
if (!updatedObject?.image) {
|
||||
updatedObject["image"] = "";
|
||||
if (!updatedObject?.content_image) {
|
||||
updatedObject["content_image"] = "";
|
||||
}
|
||||
console.log(updatedObject);
|
||||
|
||||
const oldanswers = [] as any;
|
||||
const newanswers = [] as any;
|
||||
const oldAnswers = [] as any;
|
||||
const newAnswers = [] as any;
|
||||
|
||||
updatedObject?.answers?.forEach((item: any) => {
|
||||
if (item?.id) {
|
||||
console.log(item);
|
||||
|
||||
oldanswers.push(item);
|
||||
oldAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
} else {
|
||||
newanswers.push(item);
|
||||
newAnswers.push({...item,isCorrect:item?.isCorrect ? 1 : 0});
|
||||
}
|
||||
});
|
||||
|
||||
const answers = {
|
||||
old: oldanswers,
|
||||
new: newanswers,
|
||||
old: oldAnswers,
|
||||
new: newAnswers,
|
||||
};
|
||||
console.log(answers, "answers");
|
||||
|
||||
mutate({ ...updatedObject, answers, tags });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ const ChoiceFields = ({ index, data }: { index: number; data: Choice }) => {
|
|||
return (
|
||||
<>
|
||||
<div className="ChoiceFields">
|
||||
|
||||
<TextField
|
||||
className="textarea_exercise"
|
||||
placeholder={"choice"}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,9 @@ import { Choice } from "../../../../../types/Item";
|
|||
import ChoiceFields from "./ChoiceFields";
|
||||
import { useFormikContext } from "formik";
|
||||
import { DragDropContext, Droppable, Draggable } from "react-beautiful-dnd";
|
||||
import { FaIcons } from "react-icons/fa";
|
||||
import { DragHandleUnit } from "../../../Unit/DrapableTable";
|
||||
import { HolderOutlined } from "@ant-design/icons";
|
||||
|
||||
const Choices = () => {
|
||||
const formik = useFormikContext<any>();
|
||||
|
|
@ -55,6 +58,9 @@ const Choices = () => {
|
|||
{...provided.draggableProps}
|
||||
{...provided.dragHandleProps}
|
||||
>
|
||||
<div className="HolderQuestion">
|
||||
<HolderOutlined/>
|
||||
</div>
|
||||
<ChoiceFields index={index} data={item} />
|
||||
</div>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -67,6 +67,10 @@ const Form = () => {
|
|||
};
|
||||
const [t] = useTranslation();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Row className="w-100">
|
||||
<div className="exercise_form">
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ const ChoiceFields = ({
|
|||
].answers.filter((_: any, i: any) => i !== index);
|
||||
formik.setFieldValue(`Questions[${parent_index}].answers`, updatedAnswers);
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="ChoiceFields">
|
||||
|
|
@ -60,7 +62,7 @@ const ChoiceFields = ({
|
|||
/>
|
||||
|
||||
<ImageBoxField
|
||||
name={`Questions.${parent_index}.answers.${index}.answer_image`}
|
||||
name={`Questions.${parent_index}.answers.${index}.content_image`}
|
||||
/>
|
||||
|
||||
<div className="answer_status">
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import ChoiceFields from "./ChoiceFields";
|
|||
import { Choice } from "../../../../../../types/Item";
|
||||
import { useFormikContext } from "formik";
|
||||
import { DragDropContext, Draggable, Droppable } from "react-beautiful-dnd";
|
||||
import { HolderOutlined } from "@ant-design/icons";
|
||||
|
||||
const Choices = ({ parent_index }: { parent_index: number }) => {
|
||||
const formik = useFormikContext<any>();
|
||||
|
|
@ -67,6 +68,9 @@ const Choices = ({ parent_index }: { parent_index: number }) => {
|
|||
{...provided.draggableProps}
|
||||
{...provided.dragHandleProps}
|
||||
>
|
||||
<div className="HolderQuestion">
|
||||
<HolderOutlined/>
|
||||
</div>
|
||||
<ChoiceFields
|
||||
key={index}
|
||||
parent_index={parent_index}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
|
|||
import Choices from "./ChoiceField/Choices";
|
||||
import ImageBoxField from "../../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
||||
import MaltySelectTag from "./Tags/MaltySelectTag";
|
||||
import useKeyCombination from "../../../../../Hooks/useKeyCombination";
|
||||
import { CombinationKeyEnum } from "../../../../../enums/CombinationKeyEnum";
|
||||
|
||||
const Form = () => {
|
||||
const formik = useFormikContext<any>();
|
||||
|
|
@ -36,8 +38,7 @@ const Form = () => {
|
|||
console.log(parent_index);
|
||||
|
||||
formik.setFieldValue(`Questions.[${parent_index}].answers`, [
|
||||
...((formik?.values as any)?.Questions?.[parent_index]
|
||||
.answers as Choice[]),
|
||||
...((formik?.values as any)?.Questions?.[parent_index]?.answers as Choice[]),
|
||||
|
||||
{
|
||||
answer: null,
|
||||
|
|
@ -69,7 +70,21 @@ const Form = () => {
|
|||
};
|
||||
const [t] = useTranslation();
|
||||
|
||||
|
||||
const lastQuestions = formik?.values?.Questions?.length -1 ;
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE }, () => {
|
||||
handleAddChoice(lastQuestions)
|
||||
});
|
||||
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.QUESTION }, () => {
|
||||
|
||||
handleAddQuestion()
|
||||
});
|
||||
|
||||
|
||||
|
||||
return (
|
||||
|
||||
<Row className="w-100 exercise_form_container">
|
||||
<div className="exercise_form">
|
||||
<ValidationField
|
||||
|
|
@ -78,7 +93,7 @@ const Form = () => {
|
|||
label="main_question"
|
||||
type="TextArea"
|
||||
/>
|
||||
<ImageBoxField name="image" />
|
||||
<ImageBoxField name="content_image" />
|
||||
|
||||
<div></div>
|
||||
</div>
|
||||
|
|
@ -113,7 +128,7 @@ const Form = () => {
|
|||
<ValidationField
|
||||
className=" "
|
||||
placeholder="_"
|
||||
name={`answers.${parent_index}.hint`}
|
||||
name={`Questions.${parent_index}.hint`}
|
||||
label="hint_question"
|
||||
type="text"
|
||||
style={{ width: "100%" }}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ const QuestionFIeld = ({ index, data }: { index: number; data: Choice }) => {
|
|||
type="TextArea"
|
||||
/>
|
||||
|
||||
<ImageBoxField name={`Questions.${index}.image`} />
|
||||
<ImageBoxField name={`Questions.${index}.content_image`} />
|
||||
|
||||
<div className="answer_status">
|
||||
<p className="delete_question_options">
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<div className="SelectTag">
|
||||
<label htmlFor="">{t("models.tag")}</label>
|
||||
|
|
@ -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 ? <Spin /> : t("practical.not_found")}
|
||||
|
|
@ -65,7 +75,7 @@ const MaltySelectTag = ({ parent_index }: { parent_index: number }) => {
|
|||
handleBlur();
|
||||
}
|
||||
}}
|
||||
value={values ?? []}
|
||||
value={value}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ import { useEffect } from "react";
|
|||
import Choices from "./Field/Choices";
|
||||
import ImageBoxField from "../../../../Components/CustomFields/ImageBoxField/ImageBoxField";
|
||||
import SelectTag from "../../../../Components/CustomFields/SelectTag";
|
||||
import useKeyCombination from "../../../../Hooks/useKeyCombination";
|
||||
import { CombinationKeyEnum } from "../../../../enums/CombinationKeyEnum";
|
||||
|
||||
const Form = () => {
|
||||
const [t] = useTranslation();
|
||||
|
|
@ -42,7 +44,13 @@ const Form = () => {
|
|||
]);
|
||||
};
|
||||
|
||||
console.log(formik?.values);
|
||||
|
||||
useKeyCombination({ ctrlKey: true, shiftKey: true, code: CombinationKeyEnum.CHOICE }, () => {
|
||||
|
||||
handleAddChoice()
|
||||
});
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<Row className="w-100 exercise_form_container">
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<ParamsEnum>();
|
||||
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 +
|
||||
|
|
|
|||
|
|
@ -2,12 +2,21 @@ import React from "react";
|
|||
import { useTranslation } from "react-i18next";
|
||||
import { ABILITIES_ENUM } from "../../enums/abilities";
|
||||
import useSetPageTitle from "../../Hooks/useSetPageTitle";
|
||||
import useFilter from "../../Components/FilterField/components/useFilter";
|
||||
|
||||
const Dummy = () => {
|
||||
const [t] = useTranslation();
|
||||
useSetPageTitle(`${t(ABILITIES_ENUM?.MAIN_PAGE)} / ${t("dashboard")}`);
|
||||
const {FilterButton,FilterBody} = useFilter()
|
||||
return(
|
||||
<div className="DummyHomePage">
|
||||
<FilterButton/>
|
||||
<FilterBody>
|
||||
karim
|
||||
</FilterBody>
|
||||
|
||||
return <div className="DummyHomePage"></div>;
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Dummy;
|
||||
|
|
|
|||
|
|
@ -204,4 +204,9 @@
|
|||
.add_new_button{
|
||||
padding-inline: 20px !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.HolderQuestion{
|
||||
transform: translateY(25px);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
export const BaseURL = "https://nerd-back.point-dev.net/api/";
|
||||
// export const BaseURL = "http://192.168.1.109:8000/api/";
|
||||
|
||||
export const ImageBaseURL = "https://nerd-back.point-dev.net/api/";
|
||||
export const HEADER_KEY = "X-Custom-Query-Key";
|
||||
export const HEADER_KEY = "X-Custom-Query-Key";
|
||||
6
src/enums/CombinationKeyEnum.ts
Normal file
6
src/enums/CombinationKeyEnum.ts
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
export enum CombinationKeyEnum {
|
||||
|
||||
QUESTION = "KeyK",
|
||||
CHOICE = "KeyJ"
|
||||
|
||||
}
|
||||
|
|
@ -245,7 +245,7 @@
|
|||
"Pass": "نجاح",
|
||||
"users": "المستخدمين",
|
||||
"branchAdmin": "مسؤول الفروع",
|
||||
"grade": "الدرجات",
|
||||
"grade": "الصفوف",
|
||||
"homeworkAttachment": "مرفق الواجب المنزلي",
|
||||
"lateArrival": "وصول متأخر",
|
||||
"noteAttachment": "مرفق الملاحظة",
|
||||
|
|
@ -692,7 +692,7 @@
|
|||
"tags": "كلمات مفتاحية",
|
||||
"main_menu": "القائمة الرئيسية",
|
||||
"setting": "الإعدادات",
|
||||
"grade": "الدرجات",
|
||||
"grade": "الصفوف",
|
||||
"curriculum": "مقرر",
|
||||
"package": "حزمة",
|
||||
"subjects": "مواد",
|
||||
|
|
@ -762,7 +762,7 @@
|
|||
"Question": "لوحة القيادة /اسئلة ",
|
||||
"add_Question": "لوحة القيادة /إضافة اسئلة ",
|
||||
"edit_Question": "لوحة القيادة /تعديل اسئلة ",
|
||||
"grade": "الدرجات",
|
||||
"grade": "الصفوف",
|
||||
"report": "تقرير",
|
||||
"user": "مستخدم",
|
||||
"reseller":" لوحة القيادة / البائعين",
|
||||
|
|
@ -774,31 +774,31 @@
|
|||
"reseller":"البائعين"
|
||||
},
|
||||
"alphabet": {
|
||||
"A": "أ",
|
||||
"B": "ب",
|
||||
"C": "ت",
|
||||
"D": "ث",
|
||||
"E": "ج",
|
||||
"F": "ح",
|
||||
"G": "خ",
|
||||
"H": "د",
|
||||
"I": "ذ",
|
||||
"J": "ر",
|
||||
"K": "ز",
|
||||
"L": "س",
|
||||
"M": "ش",
|
||||
"N": "ص",
|
||||
"O": "ض",
|
||||
"P": "ط",
|
||||
"Q": "ظ",
|
||||
"R": "ع",
|
||||
"S": "غ",
|
||||
"T": "ف",
|
||||
"U": "ق",
|
||||
"V": "ك",
|
||||
"W": "ل",
|
||||
"X": "م",
|
||||
"Y": "ن",
|
||||
"Z": "ه"
|
||||
"A": "A",
|
||||
"B": "B",
|
||||
"C": "C",
|
||||
"D": "D",
|
||||
"E": "E",
|
||||
"F": "F",
|
||||
"G": "G",
|
||||
"H": "H",
|
||||
"I": "I",
|
||||
"J": "J",
|
||||
"K": "K",
|
||||
"L": "L",
|
||||
"M": "M",
|
||||
"N": "N",
|
||||
"O": "O",
|
||||
"P": "P",
|
||||
"Q": "Q",
|
||||
"R": "R",
|
||||
"S": "S",
|
||||
"T": "T",
|
||||
"U": "U",
|
||||
"V": "V",
|
||||
"W": "W",
|
||||
"X": "X",
|
||||
"Y": "Y",
|
||||
"Z": "Z"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ const useAuthState = create<AuthStore>((set) => {
|
|||
const storedToken = localStorage.getItem(TOKEN_KEY);
|
||||
const storedAbilities = localStorage.getItem(ABILITIES_KEY);
|
||||
const storedType = localStorage.getItem(TYPE_KEY);
|
||||
console.log(storedAbilities);
|
||||
|
||||
return {
|
||||
isAuthenticated: !!storedToken,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user