change lower case
This commit is contained in:
parent
2c77beab03
commit
4b9a4f4d23
File diff suppressed because one or more lines are too long
|
|
@ -50,14 +50,14 @@ const HeaderSection = () => {
|
||||||
);
|
);
|
||||||
const [, setActiveButton] = useState(0);
|
const [, setActiveButton] = useState(0);
|
||||||
const { setActiveTab, ActiveTab } = useButtonState((state) => state);
|
const { setActiveTab, ActiveTab } = useButtonState((state) => state);
|
||||||
const { set_param_to_send } = useObjectToEdit();
|
const { setParamToSend } = useObjectToEdit();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const handleButtonClick = (index: number) => {
|
const handleButtonClick = (index: number) => {
|
||||||
setActiveButton(index);
|
setActiveButton(index);
|
||||||
setActiveTab(index);
|
setActiveTab(index);
|
||||||
set_param_to_send({});
|
setParamToSend({});
|
||||||
navigate(`${location.pathname}`);
|
navigate(`${location.pathname}`);
|
||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@ import { DateEnum } from '../../../enums/Date';
|
||||||
|
|
||||||
const CustomDatePicker = () => {
|
const CustomDatePicker = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const { set_param_to_send, param_to_send } = useObjectToEdit();
|
const { setParamToSend, paramToSend } = useObjectToEdit();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
||||||
const onChange: DatePickerProps["onChange"] = (date, dateString) => {
|
const onChange: DatePickerProps["onChange"] = (date, dateString) => {
|
||||||
// console.log(date, dateString);
|
// console.log(date, dateString);
|
||||||
const newObj = { ...param_to_send };
|
const newObj = { ...paramToSend };
|
||||||
newObj.date = dateString;
|
newObj.date = dateString;
|
||||||
set_param_to_send(newObj);
|
setParamToSend(newObj);
|
||||||
navigate(
|
navigate(
|
||||||
`${location.pathname}?${param_to_send?.state ?? "all"}=${dateString}`,
|
`${location.pathname}?${paramToSend?.state ?? "all"}=${dateString}`,
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
const Today = new Date() as any;
|
const Today = new Date() as any;
|
||||||
|
|
|
||||||
|
|
@ -8,19 +8,19 @@ import { QUESTION_OBJECT_KEY } from '../../config/AppKey';
|
||||||
const Header = () => {
|
const Header = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const { values, setFieldValue,setValues } = useFormikContext<any>();
|
const { values, setFieldValue,setValues } = useFormikContext<any>();
|
||||||
const {isBseQuestion,set_isBseQuestion} = useObjectToEdit()
|
const {isBseQuestion,setIsBseQuestion} = useObjectToEdit()
|
||||||
const {set_SavedQuestionData} = useObjectToEdit()
|
const {setSavedQuestionData} = useObjectToEdit()
|
||||||
const handleChange = () => {
|
const handleChange = () => {
|
||||||
set_SavedQuestionData(null)
|
setSavedQuestionData(null)
|
||||||
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
||||||
if (isBseQuestion) {
|
if (isBseQuestion) {
|
||||||
set_isBseQuestion(false)
|
setIsBseQuestion(false)
|
||||||
setValues(null)
|
setValues(null)
|
||||||
setFieldValue("isBase",0)
|
setFieldValue("isBase",0)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
set_isBseQuestion(true)
|
setIsBseQuestion(true)
|
||||||
setValues(null)
|
setValues(null)
|
||||||
setFieldValue("isBase",1)
|
setFieldValue("isBase",1)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isLoading, isSuccess } = deleteMutation;
|
const { mutate, isLoading, isSuccess } = deleteMutation;
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -33,14 +33,14 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
@ -48,7 +48,7 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
const handleKeyPress = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
if (e.key === "Enter" && object_to_edit?.[objectValue] === inputValue) {
|
if (e.key === "Enter" && objectToEdit?.[objectValue] === inputValue) {
|
||||||
handleSubmit();
|
handleSubmit();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -71,7 +71,7 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
||||||
<div className="ValidationField w-100 mb-5">
|
<div className="ValidationField w-100 mb-5">
|
||||||
<label className="text ">
|
<label className="text ">
|
||||||
{t("practical.to_confirm_deletion_please_re_enter")}{" "}
|
{t("practical.to_confirm_deletion_please_re_enter")}{" "}
|
||||||
{t(`input.${objectValue}`)} ({object_to_edit?.[objectValue]})
|
{t(`input.${objectValue}`)} ({objectToEdit?.[objectValue]})
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<Input
|
<Input
|
||||||
|
|
@ -88,11 +88,11 @@ const DeleteModels: React.FC<ModalFormProps> = ({
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.[objectValue] !== inputValue
|
objectToEdit?.[objectValue] !== inputValue
|
||||||
? "disabled_button"
|
? "disabled_button"
|
||||||
: ""
|
: ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.[objectValue] !== inputValue || isLoading}
|
disabled={objectToEdit?.[objectValue] !== inputValue || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ import { useUpdateAdmin } from "../../../api/users";
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateAdmin();
|
const { mutate, isSuccess, isLoading } = useUpdateAdmin();
|
||||||
const { set_object_to_edit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
}
|
}
|
||||||
}, [setIsOpen, isSuccess]);
|
}, [setIsOpen, isSuccess]);
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ import ModelButtons from "../../../Components/models/ModelButtons";
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { mutate, isSuccess, isLoading } = useAddTag();
|
const { mutate, isSuccess, isLoading } = useAddTag();
|
||||||
const { set_object_to_edit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
setIsOpen("isSuccess");
|
setIsOpen("isSuccess");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
}
|
}
|
||||||
}, [setIsOpen, isSuccess]);
|
}, [setIsOpen, isSuccess]);
|
||||||
|
|
||||||
|
|
@ -31,7 +31,7 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isLoading, isSuccess } = useDeleteTag();
|
const { mutate, isLoading, isSuccess } = useDeleteTag();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -22,14 +22,14 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
@ -49,7 +49,7 @@ const ModalForm: React.FC = () => {
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{t("practical.delete")} ({object_to_edit?.name}){" "}
|
{t("practical.delete")} ({objectToEdit?.name}){" "}
|
||||||
</header>
|
</header>
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
<div className="ValidationField w-100 mb-5">
|
<div className="ValidationField w-100 mb-5">
|
||||||
|
|
@ -71,9 +71,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.name !== inputValue ? "disabled_button" : ""
|
objectToEdit?.name !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.name !== inputValue || isLoading}
|
disabled={objectToEdit?.name !== inputValue || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("practical.delete")}
|
{t("practical.delete")}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ import ModelButtons from "../../../Components/models/ModelButtons";
|
||||||
|
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit(
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit(
|
||||||
(state) => state,
|
(state) => state,
|
||||||
);
|
);
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateTag();
|
const { mutate, isSuccess, isLoading } = useUpdateTag();
|
||||||
// console.log(object_to_edit,"object_to_edit");
|
// console.log(objectToEdit,"objectToEdit");
|
||||||
const handleSubmit = (values: any) => {
|
const handleSubmit = (values: any) => {
|
||||||
// const contactInformationJson = JSON.stringify({
|
// const contactInformationJson = JSON.stringify({
|
||||||
// phone_number: values?.number
|
// phone_number: values?.number
|
||||||
|
|
@ -27,7 +27,7 @@ const ModalForm: React.FC = () => {
|
||||||
};
|
};
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -45,10 +45,10 @@ const ModalForm: React.FC = () => {
|
||||||
open={isOpen === ModalEnum?.TAGS_EDIT}
|
open={isOpen === ModalEnum?.TAGS_EDIT}
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
>
|
>
|
||||||
{object_to_edit && (
|
{objectToEdit && (
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { FaTrash } from 'react-icons/fa';
|
||||||
const Tag = ({ data, index }: { data: any, index: number }) => {
|
const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { set_Tags_search ,set_currentTag} = useObjectToEdit();
|
const { setTagsSearch ,setCurrentTag} = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (inputRef.current) {
|
if (inputRef.current) {
|
||||||
|
|
@ -20,13 +20,13 @@ const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
const handleEditInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleEditInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
// console.log(e.target.value);
|
// console.log(e.target.value);
|
||||||
formik.setFieldValue(`synonyms[${index}]`, e.target.value);
|
formik.setFieldValue(`synonyms[${index}]`, e.target.value);
|
||||||
set_Tags_search(e.target.value)
|
setTagsSearch(e.target.value)
|
||||||
set_currentTag(index)
|
setCurrentTag(index)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputBlur = () => {
|
const handleInputBlur = () => {
|
||||||
// set_Tags_search(null)
|
// setTagsSearch(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteChoice = () => {
|
const handleDeleteChoice = () => {
|
||||||
|
|
@ -41,7 +41,7 @@ const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
formik.setFieldValue('synonyms', currentTags);
|
formik.setFieldValue('synonyms', currentTags);
|
||||||
|
|
||||||
// Reset search state if needed
|
// Reset search state if needed
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ import { canDeleteTags, canEditTags } from "../../utils/hasAbilityFn";
|
||||||
export const useColumns = () => {
|
export const useColumns = () => {
|
||||||
const { setIsOpen } = useModalState((state) => state);
|
const { setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const { set_object_to_edit } = useObjectToEdit((state) => state);
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const handelDelete = (record: any) => {
|
const handelDelete = (record: any) => {
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
setIsOpen(ModalEnum?.TAGS_DELETE);
|
setIsOpen(ModalEnum?.TAGS_DELETE);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
@ -43,7 +43,7 @@ export const useColumns = () => {
|
||||||
render: (text, record, index) => {
|
render: (text, record, index) => {
|
||||||
const handleEdit = (record: any) => {
|
const handleEdit = (record: any) => {
|
||||||
// console.log(record,"record");
|
// console.log(record,"record");
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
setIsOpen(ModalEnum?.TAGS_EDIT);
|
setIsOpen(ModalEnum?.TAGS_EDIT);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useDeleteUnit();
|
const { mutate, isSuccess, isLoading } = useDeleteUnit();
|
||||||
const { object_to_edit } = useObjectToEdit((state) => state);
|
const { objectToEdit } = useObjectToEdit((state) => state);
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{" "}
|
{" "}
|
||||||
{t("practical.delete")} {object_to_edit?.name}{" "}
|
{t("practical.delete")} {objectToEdit?.name}{" "}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
|
|
@ -74,9 +74,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.name !== inputValue ? "disabled_button" : ""
|
objectToEdit?.name !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.name !== inputValue || isLoading}
|
disabled={objectToEdit?.name !== inputValue || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateUnit();
|
const { mutate, isSuccess, isLoading } = useUpdateUnit();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
// console.log(object_to_edit,"object_to_edit");
|
// console.log(objectToEdit,"objectToEdit");
|
||||||
const { subject_id } = useParams();
|
const { subject_id } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -50,7 +50,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ import { canAddUnit, canDeleteUnit, canEditUnit, canShowUnit } from "../../utils
|
||||||
export const useColumns = () => {
|
export const useColumns = () => {
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
|
|
||||||
const { set_object_to_edit } = useObjectToEdit((state) => state);
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const handelShow = (record: any) => {
|
const handelShow = (record: any) => {
|
||||||
|
|
@ -25,12 +25,12 @@ export const useColumns = () => {
|
||||||
|
|
||||||
|
|
||||||
const handelDelete = (data: any) => {
|
const handelDelete = (data: any) => {
|
||||||
set_object_to_edit(data);
|
setObjectToEdit(data);
|
||||||
handel_open_model(ModalEnum?.UNIT_DELETE);
|
handel_open_model(ModalEnum?.UNIT_DELETE);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (record: any) => {
|
const handleEdit = (record: any) => {
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
handel_open_model(ModalEnum?.UNIT_EDIT);
|
handel_open_model(ModalEnum?.UNIT_EDIT);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import { ParamsEnum } from "../../../enums/params";
|
||||||
|
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useDeleteLesson();
|
const { mutate, isSuccess, isLoading } = useDeleteLesson();
|
||||||
const { object_to_edit,set_object_to_edit } = useObjectToEdit((state) => state);
|
const { objectToEdit,setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -32,7 +32,7 @@ const ModalForm: React.FC = () => {
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
@ -51,7 +51,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{" "}
|
{" "}
|
||||||
{t("practical.delete")} {object_to_edit?.name}{" "}
|
{t("practical.delete")} {objectToEdit?.name}{" "}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
|
|
@ -74,9 +74,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.name !== inputValue ? "disabled_button" : ""
|
objectToEdit?.name !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.name !== inputValue || isLoading}
|
disabled={objectToEdit?.name !== inputValue || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("practical.delete")}
|
{t("practical.delete")}
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateLesson();
|
const { mutate, isSuccess, isLoading } = useUpdateLesson();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
// console.log(object_to_edit,"object_to_edit");
|
// console.log(objectToEdit,"objectToEdit");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -53,7 +53,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { canAddLesson, canDeleteLesson, canEditLesson, canShowLesson } from "../
|
||||||
export const useColumns = () => {
|
export const useColumns = () => {
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
|
|
||||||
const { set_object_to_edit } = useObjectToEdit((state) => state);
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
|
|
||||||
const handelShow = (record: any) => {
|
const handelShow = (record: any) => {
|
||||||
|
|
@ -29,12 +29,12 @@ export const useColumns = () => {
|
||||||
|
|
||||||
|
|
||||||
const handelDelete = (data: any) => {
|
const handelDelete = (data: any) => {
|
||||||
set_object_to_edit(data);
|
setObjectToEdit(data);
|
||||||
handel_open_model(ModalEnum?.LESSON_DELETE);
|
handel_open_model(ModalEnum?.LESSON_DELETE);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (record: any) => {
|
const handleEdit = (record: any) => {
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
handel_open_model(ModalEnum?.LESSON_EDIT);
|
handel_open_model(ModalEnum?.LESSON_EDIT);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ const AddPage: React.FC = () => {
|
||||||
|
|
||||||
const {isSuccess:isSuccessAsync,mutateAsync} = useAddQuestionAsync()
|
const {isSuccess:isSuccessAsync,mutateAsync} = useAddQuestionAsync()
|
||||||
const { mutate,isSuccess, isLoading} = useAddQuestion();
|
const { mutate,isSuccess, isLoading} = useAddQuestion();
|
||||||
const {isBseQuestion,set_Tags_search,set_object_to_edit,set_Success,SavedQuestionData} = useObjectToEdit()
|
const {isBseQuestion,setTagsSearch,setObjectToEdit,setSuccess,SavedQuestionData} = useObjectToEdit()
|
||||||
|
|
||||||
const {subject_id,lesson_id} = useParams<ParamsEnum>()
|
const {subject_id,lesson_id} = useParams<ParamsEnum>()
|
||||||
const { setIsOpen } = useModalState((state) => state);
|
const { setIsOpen } = useModalState((state) => state);
|
||||||
|
|
@ -36,7 +36,7 @@ const AddPage: React.FC = () => {
|
||||||
|
|
||||||
const handleSubmit = (values: any, { resetForm }: { resetForm: () => void }) => {
|
const handleSubmit = (values: any, { resetForm }: { resetForm: () => void }) => {
|
||||||
const DataToSend = structuredClone(values);
|
const DataToSend = structuredClone(values);
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
console.log(isBseQuestion);
|
console.log(isBseQuestion);
|
||||||
|
|
||||||
if (isBseQuestion || DataToSend?.isBase === 1) {
|
if (isBseQuestion || DataToSend?.isBase === 1) {
|
||||||
|
|
@ -84,15 +84,15 @@ const AddPage: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
||||||
if (isSuccessAsync && ( SavedQuestionData?.Questions?.length > 0 ? isSuccess: true )) {
|
if (isSuccessAsync && ( SavedQuestionData?.Questions?.length > 0 ? isSuccess: true )) {
|
||||||
set_object_to_edit(null)
|
setObjectToEdit(null)
|
||||||
set_Success(true)
|
setSuccess(true)
|
||||||
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
||||||
|
|
||||||
}
|
}
|
||||||
if(isSuccess && !(SavedQuestionData?.Questions?.length)){
|
if(isSuccess && !(SavedQuestionData?.Questions?.length)){
|
||||||
toast.success(t("validation.the_possess_done_successful"))
|
toast.success(t("validation.the_possess_done_successful"))
|
||||||
set_object_to_edit(null)
|
setObjectToEdit(null)
|
||||||
set_Success(true)
|
setSuccess(true)
|
||||||
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
localStorage.removeItem(QUESTION_OBJECT_KEY)
|
||||||
}
|
}
|
||||||
}, [isSuccess,isSuccessAsync])
|
}, [isSuccess,isSuccessAsync])
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import { toast } from "react-toastify";
|
||||||
const EditPage: React.FC = () => {
|
const EditPage: React.FC = () => {
|
||||||
|
|
||||||
const {question_id,subject_id} = useParams<ParamsEnum>()
|
const {question_id,subject_id} = useParams<ParamsEnum>()
|
||||||
const {isBseQuestion,set_isBseQuestion,set_Tags_search,DeletedQuestions} = useObjectToEdit()
|
const {isBseQuestion,setIsBseQuestion,setTagsSearch,DeletedQuestions} = useObjectToEdit()
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateQuestion();
|
const { mutate, isSuccess, isLoading } = useUpdateQuestion();
|
||||||
const { mutate:DeleteQuestion} = useDeleteQuestion();
|
const { mutate:DeleteQuestion} = useDeleteQuestion();
|
||||||
|
|
@ -29,20 +29,20 @@ const EditPage: React.FC = () => {
|
||||||
|
|
||||||
const {data:Questions,isLoading:QuestionsDataLoading}= useGetAllQuestion({questionParentId:question_id ,onlyWithNoParents:false})
|
const {data:Questions,isLoading:QuestionsDataLoading}= useGetAllQuestion({questionParentId:question_id ,onlyWithNoParents:false})
|
||||||
|
|
||||||
const object_to_edit = {...data?.data,Questions:Questions?.data } ;
|
const objectToEdit = {...data?.data,Questions:Questions?.data } ;
|
||||||
|
|
||||||
const {lesson_id} = useParams()
|
const {lesson_id} = useParams()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if(object_to_edit?.isBase && isBseQuestion !== true){
|
if(objectToEdit?.isBase && isBseQuestion !== true){
|
||||||
set_isBseQuestion(true)
|
setIsBseQuestion(true)
|
||||||
|
|
||||||
}
|
}
|
||||||
}, [object_to_edit?.isBase])
|
}, [objectToEdit?.isBase])
|
||||||
|
|
||||||
|
|
||||||
const handleSubmit = (values: any) => {
|
const handleSubmit = (values: any) => {
|
||||||
const DataToSend = structuredClone(values);
|
const DataToSend = structuredClone(values);
|
||||||
set_Tags_search(null)
|
setTagsSearch(null)
|
||||||
console.log(DataToSend);
|
console.log(DataToSend);
|
||||||
|
|
||||||
if(isBseQuestion){
|
if(isBseQuestion){
|
||||||
|
|
@ -159,7 +159,7 @@ const EditPage: React.FC = () => {
|
||||||
if(dataLoading || QuestionsDataLoading){
|
if(dataLoading || QuestionsDataLoading){
|
||||||
return <SpinContainer/>
|
return <SpinContainer/>
|
||||||
}
|
}
|
||||||
if(object_to_edit?.isBase){
|
if(objectToEdit?.isBase){
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -167,7 +167,7 @@ const EditPage: React.FC = () => {
|
||||||
|
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValuesBase(object_to_edit)}
|
initialValues={getInitialValuesBase(objectToEdit)}
|
||||||
validationSchema={getValidationSchemaBase}
|
validationSchema={getValidationSchemaBase}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ const EditPage: React.FC = () => {
|
||||||
|
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,18 +11,18 @@ import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
||||||
import MathInput from "./MathInput";
|
import MathInput from "./MathInput";
|
||||||
const Form = () => {
|
const Form = () => {
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const{set_Success,Success,set_SavedQuestionData} = useObjectToEdit()
|
const{setSuccess,Success,setSavedQuestionData} = useObjectToEdit()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Success) {
|
if (Success) {
|
||||||
formik.setErrors({});
|
formik.setErrors({});
|
||||||
formik.resetForm({ values: {} });
|
formik.resetForm({ values: {} });
|
||||||
set_Success(false)
|
setSuccess(false)
|
||||||
}
|
}
|
||||||
}, [Success]);
|
}, [Success]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
set_SavedQuestionData(formik.values)
|
setSavedQuestionData(formik.values)
|
||||||
}, [formik?.values])
|
}, [formik?.values])
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isLoading, isSuccess } = useDeleteQuestion();
|
const { mutate, isLoading, isSuccess } = useDeleteQuestion();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -22,14 +22,14 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
@ -37,7 +37,7 @@ const ModalForm: React.FC = () => {
|
||||||
setInputValue(e.target.value);
|
setInputValue(e.target.value);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
console.log(object_to_edit?.id);
|
console.log(objectToEdit?.id);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|
@ -50,7 +50,7 @@ const ModalForm: React.FC = () => {
|
||||||
onCancel={handleCancel}
|
onCancel={handleCancel}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{t("practical.delete")} {t("input.id")} ({object_to_edit?.id}){" "}
|
{t("practical.delete")} {t("input.id")} ({objectToEdit?.id}){" "}
|
||||||
</header>
|
</header>
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
<div className="ValidationField w-100 mb-5">
|
<div className="ValidationField w-100 mb-5">
|
||||||
|
|
@ -72,9 +72,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.id !== inputValue ? "disabled_button" : ""
|
objectToEdit?.id !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={Number(object_to_edit?.id) !== Number(inputValue) || isLoading}
|
disabled={Number(objectToEdit?.id) !== Number(inputValue) || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("practical.delete")}
|
{t("practical.delete")}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ const Form = () => {
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { isOpen } = useModalState((state) => state);
|
const { isOpen } = useModalState((state) => state);
|
||||||
// const {data} = useGetAllQuestion();
|
// const {data} = useGetAllQuestion();
|
||||||
const{set_Success,Success,set_SavedQuestionData} = useObjectToEdit()
|
const{setSuccess,Success,setSavedQuestionData} = useObjectToEdit()
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Success) {
|
if (Success) {
|
||||||
|
|
@ -23,12 +23,12 @@ const Form = () => {
|
||||||
|
|
||||||
formik.setErrors({});
|
formik.setErrors({});
|
||||||
formik.resetForm({ values: {} });
|
formik.resetForm({ values: {} });
|
||||||
set_Success(false)
|
setSuccess(false)
|
||||||
}
|
}
|
||||||
}, [Success]);
|
}, [Success]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
set_SavedQuestionData(formik.values)
|
setSavedQuestionData(formik.values)
|
||||||
}, [formik?.values])
|
}, [formik?.values])
|
||||||
|
|
||||||
// console.log(formik?.errors);
|
// console.log(formik?.errors);
|
||||||
|
|
|
||||||
|
|
@ -13,18 +13,18 @@ import { toast } from 'react-toastify';
|
||||||
const QuestionFIeld = ({index,data}:{index:number , data :Choice }) => {
|
const QuestionFIeld = ({index,data}:{index:number , data :Choice }) => {
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
console.log(index);
|
console.log(index);
|
||||||
const {set_DeletedQuestions,DeletedQuestions} = useObjectToEdit()
|
const {setDeletedQuestions,DeletedQuestions} = useObjectToEdit()
|
||||||
|
|
||||||
const [t] = useTranslation()
|
const [t] = useTranslation()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
set_DeletedQuestions([])
|
setDeletedQuestions([])
|
||||||
}, [window?.location.pathname])
|
}, [window?.location.pathname])
|
||||||
|
|
||||||
const handleDeleteQuestion = () => {
|
const handleDeleteQuestion = () => {
|
||||||
|
|
||||||
const DeleteQuestionId = formik.values.Questions?.[index];
|
const DeleteQuestionId = formik.values.Questions?.[index];
|
||||||
if(DeleteQuestionId?.id){
|
if(DeleteQuestionId?.id){
|
||||||
set_DeletedQuestions([...DeletedQuestions,DeleteQuestionId])
|
setDeletedQuestions([...DeletedQuestions,DeleteQuestionId])
|
||||||
|
|
||||||
}
|
}
|
||||||
const updatedQuestionOptions = formik.values.Questions.filter((_:any, i:any) => i !== index);
|
const updatedQuestionOptions = formik.values.Questions.filter((_:any, i:any) => i !== index);
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ const DynamicTags = ({parent_index}:{parent_index:number}) => {
|
||||||
|
|
||||||
const formik = useFormikContext<any>()
|
const formik = useFormikContext<any>()
|
||||||
const [t] = useTranslation()
|
const [t] = useTranslation()
|
||||||
const { Tags_search ,set_Tags_search,currentTag,current_parent_index} = useObjectToEdit();
|
const { TagsSearch ,setTagsSearch,currentTag,currentParentIndex} = useObjectToEdit();
|
||||||
const {data} = useGetAllTag({
|
const {data} = useGetAllTag({
|
||||||
name : Tags_search
|
name : TagsSearch
|
||||||
})
|
})
|
||||||
const suggests = data?.data
|
const suggests = data?.data
|
||||||
|
|
||||||
|
|
@ -20,7 +20,7 @@ const DynamicTags = ({parent_index}:{parent_index:number}) => {
|
||||||
const handleAddChoice = () => {
|
const handleAddChoice = () => {
|
||||||
const length = formik?.values?.Questions?.[parent_index]?.tags.length;
|
const length = formik?.values?.Questions?.[parent_index]?.tags.length;
|
||||||
const lastElement = formik?.values?.Questions?.[parent_index]?.tags[length - 1]?.name;
|
const lastElement = formik?.values?.Questions?.[parent_index]?.tags[length - 1]?.name;
|
||||||
set_Tags_search(null)
|
setTagsSearch(null)
|
||||||
|
|
||||||
if(lastElement !== ""){
|
if(lastElement !== ""){
|
||||||
formik.setFieldValue(`Questions.[${parent_index}].tags`, [...(formik?.values as any)?.Questions?.[parent_index]?.tags as any[],
|
formik.setFieldValue(`Questions.[${parent_index}].tags`, [...(formik?.values as any)?.Questions?.[parent_index]?.tags as any[],
|
||||||
|
|
@ -45,7 +45,7 @@ const handleChoice = (item: any) => {
|
||||||
console.log(currentTag);
|
console.log(currentTag);
|
||||||
|
|
||||||
formik.setFieldValue(`Questions.[${parent_index}].tags[${currentTag}]`, {...item,key:length});
|
formik.setFieldValue(`Questions.[${parent_index}].tags[${currentTag}]`, {...item,key:length});
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -87,10 +87,10 @@ return (
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{Tags_search && current_parent_index === parent_index &&
|
{TagsSearch && currentParentIndex === parent_index &&
|
||||||
<div className="suggests">
|
<div className="suggests">
|
||||||
{suggests?.map((item:any,index:number)=>{
|
{suggests?.map((item:any,index:number)=>{
|
||||||
console.log(current_parent_index === parent_index);
|
console.log(currentParentIndex === parent_index);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='suggested' key={index} onClick={()=> handleChoice(item)}>
|
<div className='suggested' key={index} onClick={()=> handleChoice(item)}>
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ const Tag = ({ data, index,parent_index }: { data: any, index: number,parent_ind
|
||||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
const DEBOUNCE_DELAY = 500;
|
const DEBOUNCE_DELAY = 500;
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { set_Tags_search ,set_currentTag,set_current_parent_index} = useObjectToEdit();
|
const { setTagsSearch ,setCurrentTag,setCurrentParentIndex} = useObjectToEdit();
|
||||||
console.log(formik?.values?.Questions);
|
console.log(formik?.values?.Questions);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -22,14 +22,14 @@ const Tag = ({ data, index,parent_index }: { data: any, index: number,parent_ind
|
||||||
|
|
||||||
|
|
||||||
formik.setFieldValue(`Questions.[${parent_index}].tags[${index}]`, {key:parent_index, name :e.target.value , id:`${parent_index}_key`});
|
formik.setFieldValue(`Questions.[${parent_index}].tags[${index}]`, {key:parent_index, name :e.target.value , id:`${parent_index}_key`});
|
||||||
set_currentTag(index)
|
setCurrentTag(index)
|
||||||
set_current_parent_index(parent_index)
|
setCurrentParentIndex(parent_index)
|
||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutRef.current = setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
set_Tags_search(e.target.value)
|
setTagsSearch(e.target.value)
|
||||||
}, DEBOUNCE_DELAY);
|
}, DEBOUNCE_DELAY);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -48,7 +48,7 @@ const Tag = ({ data, index,parent_index }: { data: any, index: number,parent_ind
|
||||||
formik.setFieldValue(`Questions.[${parent_index}].tags`, currentTags);
|
formik.setFieldValue(`Questions.[${parent_index}].tags`, currentTags);
|
||||||
|
|
||||||
// Reset search state if needed
|
// Reset search state if needed
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,18 +10,18 @@ const DynamicTags = () => {
|
||||||
|
|
||||||
const formik = useFormikContext<any>()
|
const formik = useFormikContext<any>()
|
||||||
const [t] = useTranslation()
|
const [t] = useTranslation()
|
||||||
const { Tags_search ,set_Tags_search,currentTag} = useObjectToEdit();
|
const { TagsSearch ,setTagsSearch,currentTag} = useObjectToEdit();
|
||||||
const {data} = useGetAllTag({
|
const {data} = useGetAllTag({
|
||||||
name : Tags_search
|
name : TagsSearch
|
||||||
})
|
})
|
||||||
const suggests = data?.data
|
const suggests = data?.data
|
||||||
console.log(Tags_search);
|
console.log(TagsSearch);
|
||||||
|
|
||||||
|
|
||||||
const handleAddChoice = () => {
|
const handleAddChoice = () => {
|
||||||
const length = formik?.values?.tags.length;
|
const length = formik?.values?.tags.length;
|
||||||
const lastElement = formik?.values?.tags[length - 1]?.name;
|
const lastElement = formik?.values?.tags[length - 1]?.name;
|
||||||
set_Tags_search
|
setTagsSearch
|
||||||
if(lastElement !== ""){
|
if(lastElement !== ""){
|
||||||
formik.setFieldValue('tags', [...(formik?.values as any)?.tags as any[],
|
formik.setFieldValue('tags', [...(formik?.values as any)?.tags as any[],
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@ const handleChoice = (item: any) => {
|
||||||
console.log(currentTag);
|
console.log(currentTag);
|
||||||
|
|
||||||
formik.setFieldValue(`tags[${currentTag}]`, {...item,key:length});
|
formik.setFieldValue(`tags[${currentTag}]`, {...item,key:length});
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,7 +86,7 @@ return (
|
||||||
}
|
}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{Tags_search &&
|
{TagsSearch &&
|
||||||
<div className="suggests">
|
<div className="suggests">
|
||||||
{suggests?.map((item:any,index:number)=>{
|
{suggests?.map((item:any,index:number)=>{
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { FaTrash } from 'react-icons/fa';
|
||||||
const Tag = ({ data, index }: { data: any, index: number }) => {
|
const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const formik = useFormikContext<any>();
|
const formik = useFormikContext<any>();
|
||||||
const { set_Tags_search ,set_currentTag} = useObjectToEdit();
|
const { setTagsSearch ,setCurrentTag} = useObjectToEdit();
|
||||||
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
|
||||||
const DEBOUNCE_DELAY = 500;
|
const DEBOUNCE_DELAY = 500;
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -18,21 +18,21 @@ const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
const handleEditInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleEditInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
// console.log(e.target.value);
|
// console.log(e.target.value);
|
||||||
formik.setFieldValue(`tags[${index}].name`, e.target.value);
|
formik.setFieldValue(`tags[${index}].name`, e.target.value);
|
||||||
// set_Tags_search(e.target.value)
|
// setTagsSearch(e.target.value)
|
||||||
formik.setFieldValue(`tags.[${index}]`, {key:index, name :e.target.value , id:`${index}_key`});
|
formik.setFieldValue(`tags.[${index}]`, {key:index, name :e.target.value , id:`${index}_key`});
|
||||||
|
|
||||||
set_currentTag(index)
|
setCurrentTag(index)
|
||||||
if (timeoutRef.current) {
|
if (timeoutRef.current) {
|
||||||
clearTimeout(timeoutRef.current);
|
clearTimeout(timeoutRef.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
timeoutRef.current = setTimeout(() => {
|
timeoutRef.current = setTimeout(() => {
|
||||||
set_Tags_search(e.target.value)
|
setTagsSearch(e.target.value)
|
||||||
}, DEBOUNCE_DELAY);
|
}, DEBOUNCE_DELAY);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleInputBlur = () => {
|
const handleInputBlur = () => {
|
||||||
// set_Tags_search(null)
|
// setTagsSearch(null)
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleDeleteChoice = () => {
|
const handleDeleteChoice = () => {
|
||||||
|
|
@ -50,7 +50,7 @@ const Tag = ({ data, index }: { data: any, index: number }) => {
|
||||||
formik.setFieldValue('tags', currentTags);
|
formik.setFieldValue('tags', currentTags);
|
||||||
|
|
||||||
// Reset search state if needed
|
// Reset search state if needed
|
||||||
set_Tags_search(null);
|
setTagsSearch(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -12,24 +12,24 @@ import { useModalState } from "../../zustand/Modal";
|
||||||
import { canAddQuestion, canDeleteQuestion, canEditQuestion } from "../../utils/hasAbilityFn";
|
import { canAddQuestion, canDeleteQuestion, canEditQuestion } from "../../utils/hasAbilityFn";
|
||||||
|
|
||||||
export const useColumns = () => {
|
export const useColumns = () => {
|
||||||
const { set_object_to_edit } = useObjectToEdit((state) => state);
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const navigate = useNavigate()
|
const navigate = useNavigate()
|
||||||
const { setIsOpen } = useModalState((state) => state);
|
const { setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const handelAdd = () => {
|
const handelAdd = () => {
|
||||||
set_object_to_edit({})
|
setObjectToEdit({})
|
||||||
navigate(`${ABILITIES_ENUM?.QUESTION}/add`)
|
navigate(`${ABILITIES_ENUM?.QUESTION}/add`)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handelDelete = (data: any) => {
|
const handelDelete = (data: any) => {
|
||||||
set_object_to_edit(data);
|
setObjectToEdit(data);
|
||||||
setIsOpen(ModalEnum?.QUESTION_DELETE);
|
setIsOpen(ModalEnum?.QUESTION_DELETE);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (record: any) => {
|
const handleEdit = (record: any) => {
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
navigate(`${ABILITIES_ENUM?.QUESTION}/${record?.id}`)
|
navigate(`${ABILITIES_ENUM?.QUESTION}/${record?.id}`)
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ import { useTranslation } from "react-i18next";
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { mutate, isSuccess, isLoading } = useAddSubject();
|
const { mutate, isSuccess, isLoading } = useAddSubject();
|
||||||
const { set_object_to_edit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
}
|
}
|
||||||
}, [setIsOpen, isSuccess]);
|
}, [setIsOpen, isSuccess]);
|
||||||
|
|
||||||
|
|
@ -32,7 +32,7 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useDeleteSubject();
|
const { mutate, isSuccess, isLoading } = useDeleteSubject();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const full_name = object_to_edit?.name;
|
const full_name = objectToEdit?.name;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -24,14 +24,14 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ import { handelImageState } from "../../../utils/DataToSendImageState";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit(
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit(
|
||||||
(state) => state,
|
(state) => state,
|
||||||
);
|
);
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
|
|
@ -21,7 +21,7 @@ const ModalForm: React.FC = () => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
}
|
}
|
||||||
}, [isSuccess]);
|
}, [isSuccess]);
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@ const ModalForm: React.FC = () => {
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit(null);
|
setObjectToEdit(null);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
||||||
|
|
@ -49,7 +49,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<Formik
|
<Formik
|
||||||
enableReinitialize
|
enableReinitialize
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
onSubmit={handleSubmit}
|
onSubmit={handleSubmit}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,16 @@ import { canDeleteSubject, canEditSubject } from "../../../utils/hasAbilityFn";
|
||||||
|
|
||||||
export const useColumns = () => {
|
export const useColumns = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { set_object_to_edit } = useObjectToEdit((state) => state);
|
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
|
|
||||||
const handelDeleteSubject = (data: any) => {
|
const handelDeleteSubject = (data: any) => {
|
||||||
set_object_to_edit(data);
|
setObjectToEdit(data);
|
||||||
handel_open_model(ModalEnum?.SUBJECT_DELETE);
|
handel_open_model(ModalEnum?.SUBJECT_DELETE);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleEdit = (record: any) => {
|
const handleEdit = (record: any) => {
|
||||||
set_object_to_edit(record);
|
setObjectToEdit(record);
|
||||||
handel_open_model(ModalEnum?.SUBJECT_EDIT);
|
handel_open_model(ModalEnum?.SUBJECT_EDIT);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useDeleteUnit();
|
const { mutate, isSuccess, isLoading } = useDeleteUnit();
|
||||||
const { object_to_edit } = useObjectToEdit((state) => state);
|
const { objectToEdit } = useObjectToEdit((state) => state);
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{" "}
|
{" "}
|
||||||
{t("practical.delete")} {object_to_edit?.name}{" "}
|
{t("practical.delete")} {objectToEdit?.name}{" "}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
|
|
@ -74,9 +74,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.name !== inputValue ? "disabled_button" : ""
|
objectToEdit?.name !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.name !== inputValue || isLoading}
|
disabled={objectToEdit?.name !== inputValue || isLoading}
|
||||||
// onClick={handleSubmit}
|
// onClick={handleSubmit}
|
||||||
type="button"
|
type="button"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateUnit();
|
const { mutate, isSuccess, isLoading } = useUpdateUnit();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
// console.log(object_to_edit,"object_to_edit");
|
// console.log(objectToEdit,"objectToEdit");
|
||||||
const { subject_id } = useParams();
|
const { subject_id } = useParams();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -50,7 +50,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
|
|
@ -20,17 +20,17 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const genExtra = (
|
const genExtra = (
|
||||||
item: Unit,
|
item: Unit,
|
||||||
set_object_to_edit: any,
|
setObjectToEdit: any,
|
||||||
handel_open_model: any,
|
handel_open_model: any,
|
||||||
t: any,
|
t: any,
|
||||||
) => {
|
) => {
|
||||||
const handelDelete = (event: any, item: Unit) => {
|
const handelDelete = (event: any, item: Unit) => {
|
||||||
handel_open_model(ModalEnum?.UNIT_DELETE);
|
handel_open_model(ModalEnum?.UNIT_DELETE);
|
||||||
set_object_to_edit(item);
|
setObjectToEdit(item);
|
||||||
};
|
};
|
||||||
const handleEdit = (event: any, item: Unit) => {
|
const handleEdit = (event: any, item: Unit) => {
|
||||||
// console.log(item,"event");
|
// console.log(item,"event");
|
||||||
set_object_to_edit(item);
|
setObjectToEdit(item);
|
||||||
handel_open_model(ModalEnum?.UNIT_EDIT);
|
handel_open_model(ModalEnum?.UNIT_EDIT);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@ const genExtra = (
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const { token } = theme.useToken();
|
const { token } = theme.useToken();
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
const { set_object_to_edit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
const { subject_id } = useParams();
|
const { subject_id } = useParams();
|
||||||
|
|
||||||
const panelStyle: React.CSSProperties = {
|
const panelStyle: React.CSSProperties = {
|
||||||
|
|
@ -78,7 +78,7 @@ const App: React.FC = () => {
|
||||||
label: item?.name,
|
label: item?.name,
|
||||||
children: <Lessons unit_id={item?.id} data={item?.lessons} />,
|
children: <Lessons unit_id={item?.id} data={item?.lessons} />,
|
||||||
style: panelStyle,
|
style: panelStyle,
|
||||||
extra: genExtra(item, set_object_to_edit, handel_open_model, t),
|
extra: genExtra(item, setObjectToEdit, handel_open_model, t),
|
||||||
})) || [];
|
})) || [];
|
||||||
|
|
||||||
// console.log(units,"units");
|
// console.log(units,"units");
|
||||||
|
|
|
||||||
|
|
@ -14,19 +14,19 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const Lessons = ({ data, unit_id }: { data: Lesson[]; unit_id: number }) => {
|
const Lessons = ({ data, unit_id }: { data: Lesson[]; unit_id: number }) => {
|
||||||
const { handel_open_model } = useModalHandler();
|
const { handel_open_model } = useModalHandler();
|
||||||
const { set_object_to_edit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const handelDelete = (item: Lesson) => {
|
const handelDelete = (item: Lesson) => {
|
||||||
handel_open_model(ModalEnum?.LESSON_DELETE);
|
handel_open_model(ModalEnum?.LESSON_DELETE);
|
||||||
set_object_to_edit(item);
|
setObjectToEdit(item);
|
||||||
};
|
};
|
||||||
const handleEdit = (item: Lesson) => {
|
const handleEdit = (item: Lesson) => {
|
||||||
// console.log(item,"event");
|
// console.log(item,"event");
|
||||||
set_object_to_edit(item);
|
setObjectToEdit(item);
|
||||||
handel_open_model(ModalEnum?.LESSON_EDIT);
|
handel_open_model(ModalEnum?.LESSON_EDIT);
|
||||||
};
|
};
|
||||||
const handleAdd = () => {
|
const handleAdd = () => {
|
||||||
set_object_to_edit({ unit_id: unit_id });
|
setObjectToEdit({ unit_id: unit_id });
|
||||||
handel_open_model(ModalEnum?.LESSON_ADD);
|
handel_open_model(ModalEnum?.LESSON_ADD);
|
||||||
};
|
};
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const ModalForm: React.FC = () => {
|
const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ const ModalForm: React.FC = () => {
|
||||||
}, [setIsOpen, isSuccess, queryClient]);
|
}, [setIsOpen, isSuccess, queryClient]);
|
||||||
|
|
||||||
const handleSubmit = (values: any) => {
|
const handleSubmit = (values: any) => {
|
||||||
mutate({ ...values, unit_id: object_to_edit?.unit_id });
|
mutate({ ...values, unit_id: objectToEdit?.unit_id });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
|
|
|
||||||
|
|
@ -12,12 +12,12 @@ const ModalForm: React.FC = () => {
|
||||||
const [inputValue, setInputValue] = useState("");
|
const [inputValue, setInputValue] = useState("");
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useDeleteLesson();
|
const { mutate, isSuccess, isLoading } = useDeleteLesson();
|
||||||
const { object_to_edit } = useObjectToEdit((state) => state);
|
const { objectToEdit } = useObjectToEdit((state) => state);
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const handleSubmit = () => {
|
const handleSubmit = () => {
|
||||||
mutate({
|
mutate({
|
||||||
id: Number(object_to_edit?.id),
|
id: Number(objectToEdit?.id),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -32,7 +32,7 @@ const ModalForm: React.FC = () => {
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
setInputValue("");
|
setInputValue("");
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
set_object_to_edit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
|
|
@ -51,7 +51,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
{" "}
|
{" "}
|
||||||
{t("practical.delete")} {object_to_edit?.name}{" "}
|
{t("practical.delete")} {objectToEdit?.name}{" "}
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<main className="main_modal">
|
<main className="main_modal">
|
||||||
|
|
@ -74,9 +74,9 @@ const ModalForm: React.FC = () => {
|
||||||
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
<div onClick={handleCancel}>{t("practical.cancel")}</div>
|
||||||
<button
|
<button
|
||||||
className={
|
className={
|
||||||
object_to_edit?.name !== inputValue ? "disabled_button" : ""
|
objectToEdit?.name !== inputValue ? "disabled_button" : ""
|
||||||
}
|
}
|
||||||
disabled={object_to_edit?.name !== inputValue || isLoading}
|
disabled={objectToEdit?.name !== inputValue || isLoading}
|
||||||
onClick={handleSubmit}
|
onClick={handleSubmit}
|
||||||
>
|
>
|
||||||
{t("practical.delete")}
|
{t("practical.delete")}
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ const ModalForm: React.FC = () => {
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
|
|
||||||
const { mutate, isSuccess, isLoading } = useUpdateLesson();
|
const { mutate, isSuccess, isLoading } = useUpdateLesson();
|
||||||
const { object_to_edit, set_object_to_edit } = useObjectToEdit();
|
const { objectToEdit, setObjectToEdit } = useObjectToEdit();
|
||||||
|
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
// console.log(object_to_edit,"object_to_edit");
|
// console.log(objectToEdit,"objectToEdit");
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isSuccess) {
|
if (isSuccess) {
|
||||||
|
|
@ -53,7 +53,7 @@ const ModalForm: React.FC = () => {
|
||||||
>
|
>
|
||||||
<FormikForm
|
<FormikForm
|
||||||
handleSubmit={handleSubmit}
|
handleSubmit={handleSubmit}
|
||||||
initialValues={getInitialValues(object_to_edit)}
|
initialValues={getInitialValues(objectToEdit)}
|
||||||
validationSchema={getValidationSchema}
|
validationSchema={getValidationSchema}
|
||||||
>
|
>
|
||||||
<header>
|
<header>
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,11 @@ function useGetQuery(
|
||||||
|
|
||||||
const { page, per_page } = PaginationParams(location);
|
const { page, per_page } = PaginationParams(location);
|
||||||
|
|
||||||
const param_to_send = pagination
|
const paramToSend = pagination
|
||||||
? { ...remainingParams, page: page, per_page: per_page }
|
? { ...remainingParams, page: page, per_page: per_page }
|
||||||
: { ...remainingParams };
|
: { ...remainingParams };
|
||||||
|
|
||||||
const filteredParams = filterParams(param_to_send);
|
const filteredParams = filterParams(paramToSend);
|
||||||
|
|
||||||
return useQuery(
|
return useQuery(
|
||||||
[KEY, filteredParams, show],
|
[KEY, filteredParams, show],
|
||||||
|
|
|
||||||
|
|
@ -1,56 +1,48 @@
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
|
|
||||||
interface ModelState {
|
interface ModelState {
|
||||||
object_to_edit: any;
|
objectToEdit: any;
|
||||||
set_object_to_edit: (data: any) => void;
|
setObjectToEdit: (data: any) => void;
|
||||||
old_object_to_edit: any;
|
paramToSend: any;
|
||||||
set_old_object_to_edit: (data: any) => void;
|
setParamToSend: (data: any) => void;
|
||||||
object_ids: any;
|
TagsSearch: any;
|
||||||
set_object_ids: (data: any) => void;
|
setTagsSearch: (data: any) => void;
|
||||||
param_to_send: any;
|
TagsQuery: any;
|
||||||
set_param_to_send: (data: any) => void;
|
setTagsQuery: (data: any) => void;
|
||||||
Tags_search: any;
|
|
||||||
set_Tags_search: (data: any) => void;
|
|
||||||
Tags_query: any;
|
|
||||||
set_Tags_query: (data: any) => void;
|
|
||||||
currentTag: any;
|
currentTag: any;
|
||||||
set_currentTag: (data: any) => void;
|
setCurrentTag: (data: any) => void;
|
||||||
current_parent_index: any;
|
currentParentIndex: any;
|
||||||
set_current_parent_index: (data: any) => void;
|
setCurrentParentIndex: (data: any) => void;
|
||||||
isBseQuestion: boolean;
|
isBseQuestion: boolean;
|
||||||
set_isBseQuestion: (data: any) => void;
|
setIsBseQuestion: (data: any) => void;
|
||||||
Success: boolean;
|
Success: boolean;
|
||||||
set_Success: (data: any) => void;
|
setSuccess: (data: any) => void;
|
||||||
DeletedQuestions: any;
|
DeletedQuestions: any;
|
||||||
set_DeletedQuestions: (data: any) => void;
|
setDeletedQuestions: (data: any) => void;
|
||||||
|
|
||||||
SavedQuestionData: any;
|
SavedQuestionData: any;
|
||||||
set_SavedQuestionData: (data: any) => void;
|
setSavedQuestionData: (data: any) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useObjectToEdit = create<ModelState>((set) => ({
|
export const useObjectToEdit = create<ModelState>((set) => ({
|
||||||
object_to_edit: null,
|
objectToEdit: null,
|
||||||
set_object_to_edit: (data) => set(() => ({ object_to_edit: data })),
|
setObjectToEdit: (data) => set(() => ({ objectToEdit: data })),
|
||||||
old_object_to_edit: null,
|
paramToSend: {},
|
||||||
set_old_object_to_edit: (data) => set(() => ({ old_object_to_edit: data })),
|
setParamToSend: (data) => set(() => ({ paramToSend: data })),
|
||||||
object_ids: [],
|
TagsSearch: null,
|
||||||
set_object_ids: (data) => set(() => ({ object_ids: data })),
|
setTagsSearch: (data) => set(() => ({ TagsSearch: data })),
|
||||||
param_to_send: {},
|
TagsQuery: null,
|
||||||
set_param_to_send: (data) => set(() => ({ param_to_send: data })),
|
setTagsQuery: (data) => set(() => ({ TagsQuery: data })),
|
||||||
Tags_search: null,
|
|
||||||
set_Tags_search: (data) => set(() => ({ Tags_search: data })),
|
|
||||||
Tags_query: null,
|
|
||||||
set_Tags_query: (data) => set(() => ({ Tags_query: data })),
|
|
||||||
currentTag: null,
|
currentTag: null,
|
||||||
set_currentTag: (data) => set(() => ({ currentTag: data })),
|
setCurrentTag: (data) => set(() => ({ currentTag: data })),
|
||||||
current_parent_index: null,
|
currentParentIndex: null,
|
||||||
set_current_parent_index: (data) => set(() => ({ current_parent_index: data })),
|
setCurrentParentIndex: (data) => set(() => ({ currentParentIndex: data })),
|
||||||
isBseQuestion: false,
|
isBseQuestion: false,
|
||||||
set_isBseQuestion: (data) => set(() => ({ isBseQuestion: data })),
|
setIsBseQuestion: (data) => set(() => ({ isBseQuestion: data })),
|
||||||
Success: false,
|
Success: false,
|
||||||
set_Success: (data) => set(() => ({ Success: data })),
|
setSuccess: (data) => set(() => ({ Success: data })),
|
||||||
DeletedQuestions: [],
|
DeletedQuestions: [],
|
||||||
set_DeletedQuestions: (data) => set(() => ({ DeletedQuestions: data })),
|
setDeletedQuestions: (data) => set(() => ({ DeletedQuestions: data })),
|
||||||
SavedQuestionData: [],
|
SavedQuestionData: [],
|
||||||
set_SavedQuestionData: (data) => set(() => ({ SavedQuestionData: data })),
|
setSavedQuestionData: (data) => set(() => ({ SavedQuestionData: data })),
|
||||||
}));
|
}));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user