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