Compare commits
No commits in common. "3bdfdf799e1cb4d824b02bb4adab8ea3144caabc" and "b47626f95047aa0e07535d29a86ec5134435faa5" have entirely different histories.
3bdfdf799e
...
b47626f950
3272
package-lock.json
generated
3272
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
|
|
@ -9,7 +9,6 @@
|
||||||
"@dnd-kit/sortable": "^8.0.0",
|
"@dnd-kit/sortable": "^8.0.0",
|
||||||
"@dnd-kit/utilities": "^3.2.2",
|
"@dnd-kit/utilities": "^3.2.2",
|
||||||
"@types/katex": "^0.16.7",
|
"@types/katex": "^0.16.7",
|
||||||
"@uiw/react-markdown-preview": "^5.1.3",
|
|
||||||
"antd": "^5.17.4",
|
"antd": "^5.17.4",
|
||||||
"axios": "^1.7.2",
|
"axios": "^1.7.2",
|
||||||
"better-react-mathjax": "^2.0.3",
|
"better-react-mathjax": "^2.0.3",
|
||||||
|
|
@ -19,7 +18,6 @@
|
||||||
"i18next": "^23.11.5",
|
"i18next": "^23.11.5",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"katex": "^0.16.11",
|
"katex": "^0.16.11",
|
||||||
"leaflet": "^1.9.4",
|
|
||||||
"lottie-react": "^2.4.0",
|
"lottie-react": "^2.4.0",
|
||||||
"mathjax": "^3.2.2",
|
"mathjax": "^3.2.2",
|
||||||
"mathjax-full": "^3.2.2",
|
"mathjax-full": "^3.2.2",
|
||||||
|
|
@ -37,7 +35,6 @@
|
||||||
"react-katex": "^3.0.1",
|
"react-katex": "^3.0.1",
|
||||||
"react-latex": "^2.0.0",
|
"react-latex": "^2.0.0",
|
||||||
"react-latex-next": "^3.0.0",
|
"react-latex-next": "^3.0.0",
|
||||||
"react-leaflet": "^4.2.1",
|
|
||||||
"react-mathjax": "^1.0.1",
|
"react-mathjax": "^1.0.1",
|
||||||
"react-mathjax-preview": "^2.2.6",
|
"react-mathjax-preview": "^2.2.6",
|
||||||
"react-mathjax2": "^0.0.2",
|
"react-mathjax2": "^0.0.2",
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ const AddLaTexModal = ({name,setLatex,Latex,setIsModalOpen,isModalOpen,setCurren
|
||||||
<TextArea
|
<TextArea
|
||||||
size="large"
|
size="large"
|
||||||
showCount
|
showCount
|
||||||
maxLength={5000}
|
maxLength={1000}
|
||||||
autoSize={{ minRows: 4, maxRows: 10 }}
|
autoSize={{ minRows: 4, maxRows: 10 }}
|
||||||
style={{height:"400px"}}
|
style={{height:"400px"}}
|
||||||
onChange={handleChangeInputLatex}
|
onChange={handleChangeInputLatex}
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ const LaTeXInputMemo: React.FC<any> = React.memo(({ field ,form, label, ...prop
|
||||||
<TextArea
|
<TextArea
|
||||||
size="large"
|
size="large"
|
||||||
showCount
|
showCount
|
||||||
maxLength={5000}
|
maxLength={1000}
|
||||||
autoSize={{ minRows: 6, maxRows: 10 }}
|
autoSize={{ minRows: 6, maxRows: 10 }}
|
||||||
style={{ height: "400px" }}
|
style={{ height: "400px" }}
|
||||||
onChange={handleChangeInput}
|
onChange={handleChangeInput}
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { getInitialValues, getValidationSchema } from "./formUtil";
|
|
||||||
import { ModalEnum } from "../../../../enums/Model";
|
|
||||||
import LayoutModel from "../../../../Layout/Dashboard/LayoutModel";
|
|
||||||
import { QueryStatusEnum } from "../../../../enums/QueryStatus";
|
|
||||||
import ModelForm from "./ModelForm";
|
|
||||||
import { useAddArea } from "../../../../api/Area";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
import { ParamsEnum } from "../../../../enums/params";
|
|
||||||
|
|
||||||
const AddModel: React.FC = () => {
|
|
||||||
const { mutate, status } = useAddArea();
|
|
||||||
const {city_id} = useParams<ParamsEnum>()
|
|
||||||
const handleSubmit = (values: any) => {
|
|
||||||
mutate({
|
|
||||||
...values,
|
|
||||||
city_id
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<LayoutModel
|
|
||||||
status={status as QueryStatusEnum}
|
|
||||||
ModelEnum={ModalEnum.AREA_ADD}
|
|
||||||
modelTitle="Area"
|
|
||||||
handleSubmit={handleSubmit}
|
|
||||||
getInitialValues={getInitialValues({})}
|
|
||||||
getValidationSchema={getValidationSchema}
|
|
||||||
>
|
|
||||||
<ModelForm />
|
|
||||||
</LayoutModel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddModel;
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { getInitialValues, getValidationSchema } from "./formUtil";
|
|
||||||
import { ModalEnum } from "../../../../enums/Model";
|
|
||||||
import LayoutModel from "../../../../Layout/Dashboard/LayoutModel";
|
|
||||||
import ModelForm from "./ModelForm";
|
|
||||||
import { QueryStatusEnum } from "../../../../enums/QueryStatus";
|
|
||||||
import { useObjectToEdit } from "../../../../zustand/ObjectToEditState";
|
|
||||||
import { useUpdateArea } from "../../../../api/Area";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
import { ParamsEnum } from "../../../../enums/params";
|
|
||||||
|
|
||||||
const EditModel: React.FC = () => {
|
|
||||||
const { mutate, status } = useUpdateArea();
|
|
||||||
const { objectToEdit } = useObjectToEdit((state) => state);
|
|
||||||
const {city_id} = useParams<ParamsEnum>()
|
|
||||||
const handleSubmit = (values: any) => {
|
|
||||||
const Data_to_send = { ...values,city_id };
|
|
||||||
mutate(Data_to_send);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<LayoutModel
|
|
||||||
status={status as QueryStatusEnum}
|
|
||||||
ModelEnum={ModalEnum.AREA_EDIT}
|
|
||||||
modelTitle="Area"
|
|
||||||
handleSubmit={handleSubmit}
|
|
||||||
getInitialValues={getInitialValues(objectToEdit)}
|
|
||||||
getValidationSchema={getValidationSchema}
|
|
||||||
isAddModal={false}
|
|
||||||
>
|
|
||||||
<ModelForm />
|
|
||||||
</LayoutModel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default EditModel;
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
|
||||||
import { Col, Row } from "reactstrap";
|
|
||||||
import { useFormikContext } from "formik";
|
|
||||||
|
|
||||||
const FilterForm = () => {
|
|
||||||
const formik = useFormikContext();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Row>
|
|
||||||
<Col>
|
|
||||||
<ValidationField placeholder="name" label="name" name="name" />
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FilterForm;
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import { Col, Row } from "reactstrap";
|
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
|
||||||
|
|
||||||
const Form = () => {
|
|
||||||
return (
|
|
||||||
<Row className="w-100">
|
|
||||||
<Col>
|
|
||||||
<ValidationField name="name" placeholder="name" label="name" />
|
|
||||||
</Col>
|
|
||||||
|
|
||||||
</Row>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Form;
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import * as Yup from "yup";
|
|
||||||
import { Area, AreaInitialValues } from "../../../../types/Area";
|
|
||||||
|
|
||||||
export const getInitialValues = (
|
|
||||||
objectToEdit: Partial<Area>,
|
|
||||||
): AreaInitialValues => {
|
|
||||||
return {
|
|
||||||
id: objectToEdit?.id,
|
|
||||||
name: objectToEdit?.name ?? "",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getValidationSchema = () => {
|
|
||||||
// validate input
|
|
||||||
return Yup.object().shape({
|
|
||||||
name: Yup.string().required("validation.required"),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -1,51 +0,0 @@
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { lazy, Suspense } from "react";
|
|
||||||
import { Spin } from "antd";
|
|
||||||
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
|
|
||||||
import { ModalEnum } from "../../../enums/Model";
|
|
||||||
import { useDeleteArea } from "../../../api/Area";
|
|
||||||
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
|
||||||
import FilterLayout from "../../../Layout/Dashboard/FilterLayout";
|
|
||||||
import FilterForm from "./Model/FilterForm";
|
|
||||||
import { canAddArea } from "../../../utils/hasAbilityFn";
|
|
||||||
import { ParamsEnum } from "../../../enums/params";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
|
|
||||||
const Table = lazy(() => import("./Table"));
|
|
||||||
const AddModalForm = lazy(() => import("./Model/AddModel"));
|
|
||||||
const EditModalForm = lazy(() => import("./Model/EditModel"));
|
|
||||||
const DeleteModalForm = lazy(
|
|
||||||
() => import("../../../Layout/Dashboard/DeleteModels"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const TableHeader = () => {
|
|
||||||
const [t] = useTranslation();
|
|
||||||
const deleteMutation = useDeleteArea();
|
|
||||||
const {city_id} = useParams<ParamsEnum>()
|
|
||||||
useSetPageTitle([
|
|
||||||
{name:`${t(`page_header.home`)}`, path:"/"},
|
|
||||||
{name:`${t(`page_header.Area`)}`, path:`city/${city_id}`},
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="TableWithHeader">
|
|
||||||
<Suspense fallback={<Spin />}>
|
|
||||||
<PageHeader
|
|
||||||
pageTitle="Area"
|
|
||||||
ModelAbility={ModalEnum?.AREA_ADD}
|
|
||||||
canAdd={canAddArea}
|
|
||||||
/>
|
|
||||||
<FilterLayout sub_children={<FilterForm />} filterTitle="table.Area" haveFilter={false} />
|
|
||||||
<Table />
|
|
||||||
<AddModalForm />
|
|
||||||
<EditModalForm />
|
|
||||||
<DeleteModalForm
|
|
||||||
deleteMutation={deleteMutation}
|
|
||||||
ModelEnum={ModalEnum?.AREA_DELETE}
|
|
||||||
/>
|
|
||||||
</Suspense>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TableHeader;
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import { useColumns } from "./useTableColumns";
|
|
||||||
import React from "react";
|
|
||||||
import DataTable from "../../../Layout/Dashboard/Table/DataTable";
|
|
||||||
import { useGetAllArea } from "../../../api/Area";
|
|
||||||
import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|
||||||
import { useFilterStateState } from "../../../zustand/Filter";
|
|
||||||
import { useParams } from "react-router-dom";
|
|
||||||
import { ParamsEnum } from "../../../enums/params";
|
|
||||||
|
|
||||||
const App: React.FC = () => {
|
|
||||||
const { filterState } = useFilterState();
|
|
||||||
const { Filter } = useFilterStateState();
|
|
||||||
const {city_id} = useParams<ParamsEnum>()
|
|
||||||
const name = Filter?.name ;
|
|
||||||
const sort_by = Filter?.sort_by ;
|
|
||||||
const response = useGetAllArea({
|
|
||||||
pagination: true,
|
|
||||||
...filterState,
|
|
||||||
city_id,
|
|
||||||
name,
|
|
||||||
|
|
||||||
sort_by
|
|
||||||
});
|
|
||||||
|
|
||||||
return <DataTable response={response} useColumns={useColumns} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
|
|
@ -1,80 +0,0 @@
|
||||||
import { TableColumnsType } from "antd";
|
|
||||||
import useModalHandler from "../../../utils/useModalHandler";
|
|
||||||
import { ModalEnum } from "../../../enums/Model";
|
|
||||||
import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import {
|
|
||||||
canDeleteArea,
|
|
||||||
canEditArea,
|
|
||||||
canShowArea,
|
|
||||||
} from "../../../utils/hasAbilityFn";
|
|
||||||
import ActionButtons from "../../../Components/Table/ActionButtons";
|
|
||||||
import ColumnsImage from "../../../Components/Columns/ColumnsImage";
|
|
||||||
import { Area } from "../../../types/Area";
|
|
||||||
import { useFilterStateState } from "../../../zustand/Filter";
|
|
||||||
|
|
||||||
export const useColumns = () => {
|
|
||||||
const { handel_open_model } = useModalHandler();
|
|
||||||
|
|
||||||
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { setFilter } = useFilterStateState();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handelShow = (record: Area) => {
|
|
||||||
setFilter({})
|
|
||||||
navigate(`${record?.id}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handelDelete = (data: Area) => {
|
|
||||||
setObjectToEdit(data);
|
|
||||||
handel_open_model(ModalEnum?.AREA_DELETE);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEdit = (record: Area) => {
|
|
||||||
setObjectToEdit(record);
|
|
||||||
handel_open_model(ModalEnum?.AREA_EDIT);
|
|
||||||
};
|
|
||||||
const [t] = useTranslation();
|
|
||||||
|
|
||||||
const columns: TableColumnsType<Area> = [
|
|
||||||
{
|
|
||||||
title: t("columns.id"),
|
|
||||||
dataIndex: "id",
|
|
||||||
key: "id",
|
|
||||||
align: "center",
|
|
||||||
render: (_text, record) => record?.id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: `${t("columns.name")}`,
|
|
||||||
dataIndex: "name",
|
|
||||||
key: "name",
|
|
||||||
align: "center",
|
|
||||||
render: (_text, record) => record?.name,
|
|
||||||
ellipsis:true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
|
|
||||||
title: t("columns.procedure"),
|
|
||||||
key: "actions",
|
|
||||||
align: "center",
|
|
||||||
width: "25vw",
|
|
||||||
render: (_text, record, index) => {
|
|
||||||
return (
|
|
||||||
<ActionButtons
|
|
||||||
canDelete={canDeleteArea}
|
|
||||||
canEdit={canEditArea}
|
|
||||||
canShow={false}
|
|
||||||
index={index}
|
|
||||||
onDelete={() => handelDelete(record)}
|
|
||||||
onEdit={() => handleEdit(record)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return columns;
|
|
||||||
};
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { getInitialValues, getValidationSchema } from "./formUtil";
|
|
||||||
import { ModalEnum } from "../../../../enums/Model";
|
|
||||||
import LayoutModel from "../../../../Layout/Dashboard/LayoutModel";
|
|
||||||
import { QueryStatusEnum } from "../../../../enums/QueryStatus";
|
|
||||||
import ModelForm from "./ModelForm";
|
|
||||||
import { useAddCity } from "../../../../api/City";
|
|
||||||
|
|
||||||
const AddModel: React.FC = () => {
|
|
||||||
const { mutate, status } = useAddCity();
|
|
||||||
|
|
||||||
const handleSubmit = (values: any) => {
|
|
||||||
mutate({
|
|
||||||
...values,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<LayoutModel
|
|
||||||
status={status as QueryStatusEnum}
|
|
||||||
ModelEnum={ModalEnum.CITY_ADD}
|
|
||||||
modelTitle="City"
|
|
||||||
handleSubmit={handleSubmit}
|
|
||||||
getInitialValues={getInitialValues({})}
|
|
||||||
getValidationSchema={getValidationSchema}
|
|
||||||
>
|
|
||||||
<ModelForm />
|
|
||||||
</LayoutModel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default AddModel;
|
|
||||||
|
|
@ -1,37 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import { getInitialValues, getValidationSchema } from "./formUtil";
|
|
||||||
import { ModalEnum } from "../../../../enums/Model";
|
|
||||||
import LayoutModel from "../../../../Layout/Dashboard/LayoutModel";
|
|
||||||
import ModelForm from "./ModelForm";
|
|
||||||
import { QueryStatusEnum } from "../../../../enums/QueryStatus";
|
|
||||||
import { useObjectToEdit } from "../../../../zustand/ObjectToEditState";
|
|
||||||
import { useUpdateCity } from "../../../../api/City";
|
|
||||||
import { handelImageState } from "../../../../utils/DataToSendImageState";
|
|
||||||
|
|
||||||
const EditModel: React.FC = () => {
|
|
||||||
const { mutate, status } = useUpdateCity();
|
|
||||||
const { objectToEdit } = useObjectToEdit((state) => state);
|
|
||||||
|
|
||||||
const handleSubmit = (values: any) => {
|
|
||||||
const Data_to_send = { ...values };
|
|
||||||
mutate(Data_to_send);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<LayoutModel
|
|
||||||
status={status as QueryStatusEnum}
|
|
||||||
ModelEnum={ModalEnum.CITY_EDIT}
|
|
||||||
modelTitle="City"
|
|
||||||
handleSubmit={handleSubmit}
|
|
||||||
getInitialValues={getInitialValues(objectToEdit)}
|
|
||||||
getValidationSchema={getValidationSchema}
|
|
||||||
isAddModal={false}
|
|
||||||
>
|
|
||||||
<ModelForm />
|
|
||||||
</LayoutModel>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default EditModel;
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import React from "react";
|
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
|
||||||
import { Col, Row } from "reactstrap";
|
|
||||||
import { useFormikContext } from "formik";
|
|
||||||
|
|
||||||
const FilterForm = () => {
|
|
||||||
const formik = useFormikContext();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div>
|
|
||||||
<Row>
|
|
||||||
<Col>
|
|
||||||
<ValidationField placeholder="name" label="name" name="name" />
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default FilterForm;
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
import { Col, Row } from "reactstrap";
|
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
|
||||||
|
|
||||||
const Form = () => {
|
|
||||||
return (
|
|
||||||
<Row className="w-100">
|
|
||||||
<Col>
|
|
||||||
<ValidationField name="name" placeholder="name" label="name" />
|
|
||||||
</Col>
|
|
||||||
|
|
||||||
</Row>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default Form;
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
import * as Yup from "yup";
|
|
||||||
import { City, CityInitialValues } from "../../../../types/City";
|
|
||||||
|
|
||||||
export const getInitialValues = (
|
|
||||||
objectToEdit: Partial<City>,
|
|
||||||
): CityInitialValues => {
|
|
||||||
return {
|
|
||||||
id: objectToEdit?.id,
|
|
||||||
name: objectToEdit?.name ?? "",
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getValidationSchema = () => {
|
|
||||||
// validate input
|
|
||||||
return Yup.object().shape({
|
|
||||||
name: Yup.string().required("validation.required"),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { lazy, Suspense } from "react";
|
|
||||||
import { Spin } from "antd";
|
|
||||||
import useSetPageTitle from "../../../Hooks/useSetPageTitle";
|
|
||||||
import { ModalEnum } from "../../../enums/Model";
|
|
||||||
import { useDeleteCity } from "../../../api/City";
|
|
||||||
import PageHeader from "../../../Layout/Dashboard/PageHeader";
|
|
||||||
import FilterLayout from "../../../Layout/Dashboard/FilterLayout";
|
|
||||||
import FilterForm from "./Model/FilterForm";
|
|
||||||
import { canAddCity } from "../../../utils/hasAbilityFn";
|
|
||||||
|
|
||||||
const Table = lazy(() => import("./Table"));
|
|
||||||
const AddModalForm = lazy(() => import("./Model/AddModel"));
|
|
||||||
const EditModalForm = lazy(() => import("./Model/EditModel"));
|
|
||||||
const DeleteModalForm = lazy(
|
|
||||||
() => import("../../../Layout/Dashboard/DeleteModels"),
|
|
||||||
);
|
|
||||||
|
|
||||||
const TableHeader = () => {
|
|
||||||
const [t] = useTranslation();
|
|
||||||
const deleteMutation = useDeleteCity();
|
|
||||||
|
|
||||||
useSetPageTitle([
|
|
||||||
{name:`${t(`page_header.home`)}`, path:"/"},
|
|
||||||
{name:`${t(`page_header.City`)}`, path:"City"}
|
|
||||||
]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="TableWithHeader">
|
|
||||||
<Suspense fallback={<Spin />}>
|
|
||||||
<PageHeader
|
|
||||||
pageTitle="City"
|
|
||||||
ModelAbility={ModalEnum?.CITY_ADD}
|
|
||||||
canAdd={canAddCity}
|
|
||||||
/>
|
|
||||||
<FilterLayout sub_children={<FilterForm />} filterTitle="table.City" />
|
|
||||||
<Table />
|
|
||||||
<AddModalForm />
|
|
||||||
<EditModalForm />
|
|
||||||
<DeleteModalForm
|
|
||||||
deleteMutation={deleteMutation}
|
|
||||||
ModelEnum={ModalEnum?.CITY_DELETE}
|
|
||||||
/>
|
|
||||||
</Suspense>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TableHeader;
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
import { useColumns } from "./useTableColumns";
|
|
||||||
import React from "react";
|
|
||||||
import DataTable from "../../../Layout/Dashboard/Table/DataTable";
|
|
||||||
import { useGetAllCity } from "../../../api/City";
|
|
||||||
import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
|
|
||||||
import { useFilterStateState } from "../../../zustand/Filter";
|
|
||||||
|
|
||||||
const App: React.FC = () => {
|
|
||||||
const { filterState } = useFilterState();
|
|
||||||
const { Filter } = useFilterStateState();
|
|
||||||
const name = Filter?.name ;
|
|
||||||
const sort_by = Filter?.sort_by ;
|
|
||||||
const response = useGetAllCity({
|
|
||||||
pagination: true,
|
|
||||||
...filterState,
|
|
||||||
name,
|
|
||||||
sort_by
|
|
||||||
});
|
|
||||||
|
|
||||||
return <DataTable response={response} useColumns={useColumns} />;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default App;
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
import { TableColumnsType } from "antd";
|
|
||||||
import useModalHandler from "../../../utils/useModalHandler";
|
|
||||||
import { ModalEnum } from "../../../enums/Model";
|
|
||||||
import { useObjectToEdit } from "../../../zustand/ObjectToEditState";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { useNavigate } from "react-router-dom";
|
|
||||||
import {
|
|
||||||
canDeleteCity,
|
|
||||||
canEditCity,
|
|
||||||
canShowCity,
|
|
||||||
} from "../../../utils/hasAbilityFn";
|
|
||||||
import ActionButtons from "../../../Components/Table/ActionButtons";
|
|
||||||
import ColumnsImage from "../../../Components/Columns/ColumnsImage";
|
|
||||||
import { City } from "../../../types/City";
|
|
||||||
import { useFilterStateState } from "../../../zustand/Filter";
|
|
||||||
|
|
||||||
export const useColumns = () => {
|
|
||||||
const { handel_open_model } = useModalHandler();
|
|
||||||
|
|
||||||
const { setObjectToEdit } = useObjectToEdit((state) => state);
|
|
||||||
const navigate = useNavigate();
|
|
||||||
const { setFilter } = useFilterStateState();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const handelShow = (record: City) => {
|
|
||||||
setFilter({})
|
|
||||||
navigate(`${record?.id}`);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handelDelete = (data: City) => {
|
|
||||||
setObjectToEdit(data);
|
|
||||||
handel_open_model(ModalEnum?.CITY_DELETE);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleEdit = (record: City) => {
|
|
||||||
setObjectToEdit(record);
|
|
||||||
handel_open_model(ModalEnum?.CITY_EDIT);
|
|
||||||
};
|
|
||||||
const [t] = useTranslation();
|
|
||||||
|
|
||||||
const columns: TableColumnsType<City> = [
|
|
||||||
{
|
|
||||||
title: t("columns.id"),
|
|
||||||
dataIndex: "id",
|
|
||||||
key: "id",
|
|
||||||
align: "center",
|
|
||||||
render: (_text, record) => record?.id,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: `${t("columns.name")}`,
|
|
||||||
dataIndex: "name",
|
|
||||||
key: "name",
|
|
||||||
align: "center",
|
|
||||||
render: (_text, record) => record?.name,
|
|
||||||
ellipsis:true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
|
|
||||||
title: t("columns.procedure"),
|
|
||||||
key: "actions",
|
|
||||||
align: "center",
|
|
||||||
width: "25vw",
|
|
||||||
render: (_text, record, index) => {
|
|
||||||
return (
|
|
||||||
<ActionButtons
|
|
||||||
canDelete={canDeleteCity}
|
|
||||||
canEdit={canEditCity}
|
|
||||||
canShow={canShowCity}
|
|
||||||
index={index}
|
|
||||||
onDelete={() => handelDelete(record)}
|
|
||||||
onEdit={() => handleEdit(record)}
|
|
||||||
onShow={() => handelShow(record)}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
return columns;
|
|
||||||
};
|
|
||||||
|
|
@ -2,8 +2,6 @@ import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { FaImage } from "react-icons/fa";
|
import { FaImage } from "react-icons/fa";
|
||||||
import ImageBoxField from "./ImageBoxField/ImageBoxField";
|
import ImageBoxField from "./ImageBoxField/ImageBoxField";
|
||||||
import ValidationField from "../../../../Components/ValidationField/ValidationField";
|
|
||||||
import MyMap from "../field/MyMap";
|
|
||||||
|
|
||||||
const AttachmentForm = () => {
|
const AttachmentForm = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
|
|
@ -14,17 +12,10 @@ const AttachmentForm = () => {
|
||||||
<FaImage />
|
<FaImage />
|
||||||
<h4>{t("header.attachment")}</h4>
|
<h4>{t("header.attachment")}</h4>
|
||||||
</header>
|
</header>
|
||||||
<div className="AttachmentFormBody ">
|
<main className="main_form_body">
|
||||||
<main className="main_form_body">
|
|
||||||
<ImageBoxField name="personal_image" />
|
<ImageBoxField name="personal_image" />
|
||||||
<ImageBoxField name="id_image" />
|
<ImageBoxField name="id_image" />
|
||||||
</main>
|
</main>
|
||||||
<div className="MapField">
|
|
||||||
<ValidationField name="lat" placeholder="lat" label="lat" />
|
|
||||||
<ValidationField name="lng" placeholder="lng" label="lng" />
|
|
||||||
<MyMap/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,6 @@ interface PersonalDetailsForm {
|
||||||
username: string | null;
|
username: string | null;
|
||||||
password: string | null;
|
password: string | null;
|
||||||
area_id: number | null;
|
area_id: number | null;
|
||||||
lat:number,
|
|
||||||
lng:number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PersonalDetailsEditForm {
|
interface PersonalDetailsEditForm {
|
||||||
|
|
@ -37,12 +35,10 @@ interface PersonalDetailsEditForm {
|
||||||
card_number: string | null;
|
card_number: string | null;
|
||||||
user: User;
|
user: User;
|
||||||
area_id: number | null;
|
area_id: number | null;
|
||||||
lat:number,
|
|
||||||
lng:number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getInitialValues = (objectToEdit: Partial<PersonalDetailsForm>) => {
|
export const getInitialValues = (objectToEdit: Partial<PersonalDetailsForm>) => {
|
||||||
const location = objectToEdit?.location?.[0] || { lat: 33.5138, lng: 36.2765 };
|
const location = objectToEdit?.location?.[0] || { lat: 0, lng: 0 };
|
||||||
return {
|
return {
|
||||||
id: objectToEdit?.id ?? 0,
|
id: objectToEdit?.id ?? 0,
|
||||||
first_name: objectToEdit?.first_name ?? null,
|
first_name: objectToEdit?.first_name ?? null,
|
||||||
|
|
@ -55,8 +51,6 @@ export const getInitialValues = (objectToEdit: Partial<PersonalDetailsForm>) =>
|
||||||
username: objectToEdit?.username ?? null,
|
username: objectToEdit?.username ?? null,
|
||||||
password: objectToEdit?.password ?? null,
|
password: objectToEdit?.password ?? null,
|
||||||
area_id: objectToEdit?.area_id ?? null,
|
area_id: objectToEdit?.area_id ?? null,
|
||||||
lat: location.lat ?? 33.5138,
|
|
||||||
lng: location.lng ?? 36.2765,
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
|
||||||
import { MapContainer, TileLayer, Marker, Popup, useMapEvents, useMap } from 'react-leaflet';
|
|
||||||
import 'leaflet/dist/leaflet.css';
|
|
||||||
import L from 'leaflet';
|
|
||||||
import { Input, Button } from 'antd';
|
|
||||||
import { useFormikContext } from 'formik';
|
|
||||||
import { ReSellerInitialValues } from '../../../../types/ReSeller';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
|
||||||
|
|
||||||
// Fix for marker icon issue
|
|
||||||
//@ts-ignore
|
|
||||||
delete L.Icon.Default.prototype._getIconUrl;
|
|
||||||
L.Icon.Default.mergeOptions({
|
|
||||||
iconRetinaUrl: 'https://unpkg.com/leaflet/dist/images/marker-icon-2x.png',
|
|
||||||
iconUrl: 'https://unpkg.com/leaflet/dist/images/marker-icon.png',
|
|
||||||
shadowUrl: 'https://unpkg.com/leaflet/dist/images/marker-shadow.png',
|
|
||||||
});
|
|
||||||
|
|
||||||
const LocationMarker: React.FC = () => {
|
|
||||||
const { setFieldValue } = useFormikContext<ReSellerInitialValues>();
|
|
||||||
|
|
||||||
useMapEvents({
|
|
||||||
click(e) {
|
|
||||||
const { lat, lng } = e.latlng;
|
|
||||||
setFieldValue('lat', lat); // Update latitude in Formik
|
|
||||||
setFieldValue('lng', lng); // Update longitude in Formik
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const CenterMapOnPosition: React.FC<{ position: [number, number] }> = ({ position }) => {
|
|
||||||
const map = useMap();
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
map.setView(position, map.getZoom());
|
|
||||||
}, [position, map]);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const MyMap: React.FC = () => {
|
|
||||||
const [showMap, setShowMap] = useState(false); // State to control map visibility
|
|
||||||
const [currentPosition] = useState<[number, number] | null>(null); // State to hold current position
|
|
||||||
const { values } = useFormikContext<ReSellerInitialValues>();
|
|
||||||
const { lat, lng } = values as any;
|
|
||||||
const position: [number, number] = [lat, lng];
|
|
||||||
|
|
||||||
const [t] = useTranslation()
|
|
||||||
return (
|
|
||||||
<div className='mb-4'>
|
|
||||||
<div className='MapInputs '>
|
|
||||||
<Button className='mb-4' onClick={() => setShowMap(!showMap)} type="primary">
|
|
||||||
{showMap ? `${t("practical.Hide")} ${t("practical.Map")}` : `${t("practical.Show")} ${t("practical.Map")}`}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{showMap && (
|
|
||||||
<MapContainer
|
|
||||||
center={currentPosition || position} // Use currentPosition if available, otherwise fallback to form values
|
|
||||||
zoom={13}
|
|
||||||
style={{ height: "200px", width: "100%" }}
|
|
||||||
>
|
|
||||||
<TileLayer
|
|
||||||
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
|
|
||||||
|
|
||||||
|
|
||||||
/>
|
|
||||||
<Marker position={currentPosition || position}>
|
|
||||||
|
|
||||||
</Marker>
|
|
||||||
<LocationMarker />
|
|
||||||
<CenterMapOnPosition position={currentPosition || position} />
|
|
||||||
</MapContainer>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default MyMap;
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
export const formatAbilityData = (Data: any[]) => {
|
|
||||||
const newArray: Array<{ name: any; [key: string]: boolean }> = [];
|
|
||||||
console.log(Data, "Data");
|
|
||||||
for (let i = 0; i < Data.length; i++) {
|
|
||||||
const currentObject = Data?.[i];
|
|
||||||
console.log(currentObject);
|
|
||||||
const newObjectShape = {
|
|
||||||
name: currentObject?.name,
|
|
||||||
delete: typeof currentObject?.delete === "boolean" ? false : "disabled",
|
|
||||||
index: typeof currentObject?.index === "boolean" ? false : "disabled",
|
|
||||||
show: typeof currentObject?.show === "boolean" ? false : "disabled",
|
|
||||||
store: typeof currentObject?.store === "boolean" ? false : "disabled",
|
|
||||||
update: typeof currentObject?.update === "boolean" ? false : "disabled",
|
|
||||||
} as any;
|
|
||||||
console.log(newObjectShape);
|
|
||||||
|
|
||||||
newArray.push(newObjectShape);
|
|
||||||
}
|
|
||||||
|
|
||||||
return newArray;
|
|
||||||
};
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
export const formatArrayToPermissions = ( newArray: Array<{ name: any; [key: string]: boolean }>): string[] => {
|
|
||||||
const Data: string[] = [];
|
|
||||||
|
|
||||||
newArray.forEach((obj) => {
|
|
||||||
const permission = obj.name;
|
|
||||||
Object.keys(obj).forEach((key) => {
|
|
||||||
if (key !== "name" && key !== "ALL" && obj[key] && obj[key] === true) {
|
|
||||||
Data.push(`${permission}::${key}`);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
return Data;
|
|
||||||
};
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
||||||
export const mergePermissionsWithAbilities = (
|
|
||||||
newShapeArray: Record<any, any>[],
|
|
||||||
Ability: Record<any, boolean | "disabled" | "string">[]
|
|
||||||
) => {
|
|
||||||
const newShapeMap = new Map(newShapeArray.map((item) => [item.name, item]));
|
|
||||||
console.log(newShapeMap, "newShapeMap");
|
|
||||||
|
|
||||||
return Ability.map((abilityItem) => {
|
|
||||||
const correspondingNewShape = newShapeMap.get(abilityItem.name);
|
|
||||||
console.log(correspondingNewShape);
|
|
||||||
|
|
||||||
let ALL = false;
|
|
||||||
if (correspondingNewShape) {
|
|
||||||
if (
|
|
||||||
correspondingNewShape["index"] &&
|
|
||||||
correspondingNewShape["show"] &&
|
|
||||||
correspondingNewShape["store"] &&
|
|
||||||
correspondingNewShape["update"] &&
|
|
||||||
correspondingNewShape["delete"]
|
|
||||||
) {
|
|
||||||
ALL = true;
|
|
||||||
}
|
|
||||||
console.log(correspondingNewShape);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...abilityItem,
|
|
||||||
delete:
|
|
||||||
typeof correspondingNewShape.delete === "boolean"
|
|
||||||
? correspondingNewShape.delete
|
|
||||||
: "disabled",
|
|
||||||
index:
|
|
||||||
typeof correspondingNewShape.index === "boolean"
|
|
||||||
? correspondingNewShape.index
|
|
||||||
: "disabled",
|
|
||||||
show:
|
|
||||||
typeof correspondingNewShape.show === "boolean"
|
|
||||||
? correspondingNewShape.show
|
|
||||||
: "disabled",
|
|
||||||
store:
|
|
||||||
typeof correspondingNewShape.store === "boolean"
|
|
||||||
? correspondingNewShape.store
|
|
||||||
: "disabled",
|
|
||||||
update:
|
|
||||||
typeof correspondingNewShape.update === "boolean"
|
|
||||||
? correspondingNewShape.update
|
|
||||||
: "disabled",
|
|
||||||
ALL: ALL,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return original ability item if no match found
|
|
||||||
return abilityItem;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
@ -1,31 +0,0 @@
|
||||||
export const transformPermissions = (Data: string[]) => {
|
|
||||||
const newArray: Array<{ name: any; [key: string]: boolean }> = [];
|
|
||||||
const hashMap = new Map<string, number>();
|
|
||||||
|
|
||||||
for (let i = 0; i < Data.length; i++) {
|
|
||||||
const [permission, value] = Data[i].split("::");
|
|
||||||
const existingIndex = hashMap.get(permission);
|
|
||||||
|
|
||||||
if (existingIndex !== undefined) {
|
|
||||||
if (value) {
|
|
||||||
newArray[existingIndex][value] = true;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
newArray[existingIndex]["index"] &&
|
|
||||||
newArray[existingIndex]["show"] &&
|
|
||||||
newArray[existingIndex]["store"] &&
|
|
||||||
newArray[existingIndex]["update"] &&
|
|
||||||
newArray[existingIndex]["delete"]
|
|
||||||
) {
|
|
||||||
newArray[existingIndex]["ALL"] = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const newObject = value
|
|
||||||
? ({ name: permission, [value]: true } as any)
|
|
||||||
: { name: permission };
|
|
||||||
newArray.push(newObject);
|
|
||||||
hashMap.set(permission, newArray.length - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return newArray;
|
|
||||||
};
|
|
||||||
|
|
@ -2,26 +2,24 @@ import React from 'react'
|
||||||
import DataTable from '../../../../Layout/Dashboard/Table/DataTable'
|
import DataTable from '../../../../Layout/Dashboard/Table/DataTable'
|
||||||
import { useColumns } from './useTableColumns'
|
import { useColumns } from './useTableColumns'
|
||||||
import { useFormikContext } from 'formik'
|
import { useFormikContext } from 'formik'
|
||||||
import { TableProps } from 'antd'
|
|
||||||
|
|
||||||
|
const FormTable = ({response}:{response:any}) => {
|
||||||
interface IFormTable extends TableProps {
|
|
||||||
response:any
|
|
||||||
}
|
|
||||||
const FormTable = ({response,...props}:IFormTable) => {
|
|
||||||
const {values} = useFormikContext<any>()
|
const {values} = useFormikContext<any>()
|
||||||
|
console.log(response);
|
||||||
return (
|
const data = response?.data?.data?.abilities ;
|
||||||
|
console.log(data);
|
||||||
|
|
||||||
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
response={response}
|
response={response}
|
||||||
useColumns={useColumns}
|
useColumns={useColumns}
|
||||||
dataSource={values}
|
dataSource={data}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
loading={false}
|
loading={false}
|
||||||
rowKey={"name"}
|
rowKey={"name"}
|
||||||
{...props}
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -22,11 +22,11 @@ const TableHeader = () => {
|
||||||
pageTitle="role"
|
pageTitle="role"
|
||||||
addModal={false}
|
addModal={false}
|
||||||
/>
|
/>
|
||||||
{/* <FilterLayout
|
<FilterLayout
|
||||||
sub_children={""}
|
sub_children={""}
|
||||||
filterTitle="page_header.permissions"
|
filterTitle="page_header.permissions"
|
||||||
haveFilter={false}
|
haveFilter={false}
|
||||||
/> */}
|
/>
|
||||||
|
|
||||||
<Table />
|
<Table />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,13 @@
|
||||||
import React, { Suspense } from "react";
|
import React from "react";
|
||||||
import { useFilterState } from "../../../../Components/Utils/Filter/FilterState";
|
import { useFilterState } from "../../../../Components/Utils/Filter/FilterState";
|
||||||
import { useFilterStateState } from "../../../../zustand/Filter";
|
import { useFilterStateState } from "../../../../zustand/Filter";
|
||||||
|
import { useAddPermissions, useGetAllPermissions } from "../../../../api/Permissions";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import { ParamsEnum } from "../../../../enums/params";
|
import { ParamsEnum } from "../../../../enums/params";
|
||||||
import { Form, Formik } from "formik";
|
import { Form, Formik } from "formik";
|
||||||
import FormTable from "./FormTable";
|
import FormTable from "./FormTable";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useGetAllRole, useUpdateRole } from "../../../../api/role";
|
import { useGetAllRole } from "../../../../api/role";
|
||||||
import { useGetAllAbility } from "../../../../api/Ability";
|
|
||||||
import LoadingLottie from "../../../../Components/Lottie/Loading/LoadingLottie";
|
|
||||||
import { Button } from "antd";
|
|
||||||
import { transformPermissions } from "./FN/transformPermissions";
|
|
||||||
import { formatAbilityData } from "./FN/formatAbilityData";
|
|
||||||
import { mergePermissionsWithAbilities } from "./FN/mergePermissionsWithAbilities";
|
|
||||||
import { formatArrayToPermissions } from "./FN/formatArrayToPermission";
|
|
||||||
|
|
||||||
const App: React.FC = () => {
|
const App: React.FC = () => {
|
||||||
const { role_id } = useParams<ParamsEnum>();
|
const { role_id } = useParams<ParamsEnum>();
|
||||||
|
|
@ -22,74 +16,93 @@ const App: React.FC = () => {
|
||||||
const name = Filter?.name;
|
const name = Filter?.name;
|
||||||
const sort_by = Filter?.sort_by;
|
const sort_by = Filter?.sort_by;
|
||||||
|
|
||||||
|
const Data = [
|
||||||
|
"absence::delete",
|
||||||
|
"absence::index",
|
||||||
|
"absence::show",
|
||||||
|
"absence::store",
|
||||||
|
"absence::update",
|
||||||
|
"admin::delete",
|
||||||
|
"admin::index",
|
||||||
|
"admin::show",
|
||||||
|
"admin::update",
|
||||||
|
];
|
||||||
|
|
||||||
const response = useGetAllRole({
|
const response = useGetAllRole({
|
||||||
pagination: true,
|
pagination: true,
|
||||||
show: role_id,
|
show:role_id,
|
||||||
name,
|
name,
|
||||||
sort_by,
|
sort_by,
|
||||||
...filterState,
|
...filterState,
|
||||||
});
|
});
|
||||||
const { data, isLoading } = useGetAllAbility();
|
/// time complexity O(n) -_-
|
||||||
const AllAbilityData = data?.data ?? [];
|
|
||||||
const currentData = response?.data?.data?.abilities ?? [];
|
|
||||||
|
|
||||||
|
const changePermissionShape = (Data:string[])=>{
|
||||||
const AllAbility = transformPermissions(AllAbilityData ?? []);
|
const newArray: Array<{ name: any; [key: string]: boolean }> = [];
|
||||||
|
const hashMap = new Map<string, number>();
|
||||||
|
|
||||||
|
for (let i = 0; i < Data.length; i++) {
|
||||||
|
const [permission, value] = Data[i].split("::");
|
||||||
|
const existingIndex = hashMap.get(permission);
|
||||||
|
|
||||||
|
if (existingIndex !== undefined) {
|
||||||
|
newArray[existingIndex][value] = true;
|
||||||
|
if(newArray[existingIndex]["index"] && newArray[existingIndex]["show"] && newArray[existingIndex]["store"] && newArray[existingIndex]["update"] && newArray[existingIndex]["delete"]){
|
||||||
|
newArray[existingIndex]["ALL"] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const newObject = { name: permission, [value]: true } as any;
|
||||||
|
newArray.push(newObject);
|
||||||
|
hashMap.set(permission, newArray.length - 1);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newArray
|
||||||
|
}
|
||||||
|
const newShapeArray = changePermissionShape(Data)
|
||||||
|
|
||||||
|
const [t] = useTranslation()
|
||||||
|
|
||||||
const Ability = formatAbilityData(AllAbility) ?? [];
|
console.log(response,"response");
|
||||||
const newShapeArray = transformPermissions([...currentData]);
|
|
||||||
|
|
||||||
|
const reverseChangePermissionShape = (
|
||||||
const finalShape = mergePermissionsWithAbilities(newShapeArray, Ability);
|
newArray: Array<{ name: any; [key: string]: boolean }>
|
||||||
|
): string[] => {
|
||||||
const [t] = useTranslation();
|
const Data: string[] = [];
|
||||||
|
|
||||||
const { mutate, isLoading: UpdateLoading } = useUpdateRole();
|
newArray.forEach((obj) => {
|
||||||
const handelSubmit = (values: any) => {
|
const permission = obj.name;
|
||||||
console.log(values);
|
Object.keys(obj).forEach((key) => {
|
||||||
|
if (key !== "name" && key !== "ALL" && obj[key]) {
|
||||||
const dataToSend = formatArrayToPermissions(values);
|
Data.push(`${permission}::${key}`);
|
||||||
console.log(dataToSend);
|
}
|
||||||
mutate({
|
});
|
||||||
id: role_id,
|
|
||||||
abilities: dataToSend?.length > 0 ? dataToSend : "",
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return Data;
|
||||||
};
|
};
|
||||||
const disabled =
|
const {mutate} = useAddPermissions()
|
||||||
isLoading || response.isLoading || response.isRefetching || UpdateLoading;
|
const handelSubmit = (values:any)=>{
|
||||||
return (
|
const dataToSend = reverseChangePermissionShape(values);
|
||||||
<Formik initialValues={finalShape} onSubmit={handelSubmit} enableReinitialize>
|
mutate(dataToSend)
|
||||||
{({ dirty }) => {
|
}
|
||||||
return (
|
|
||||||
<Form>
|
|
||||||
<div className="permissions_submit_button mt-4">
|
|
||||||
<Button
|
|
||||||
className="button"
|
|
||||||
disabled={disabled || !dirty}
|
|
||||||
htmlType="submit"
|
|
||||||
>
|
|
||||||
{t("practical.submit")}
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<FormTable
|
return (
|
||||||
response={response}
|
<Formik initialValues={newShapeArray} onSubmit={handelSubmit} enableReinitialize>
|
||||||
loading={{
|
{({handleSubmit})=>{
|
||||||
spinning: disabled,
|
return (
|
||||||
indicator: (
|
<Form>
|
||||||
<Suspense fallback={<></>}>
|
|
||||||
<LoadingLottie />
|
<FormTable response={response} />
|
||||||
</Suspense>
|
<div className="permissions_submit_button">
|
||||||
),
|
<button className="button" onClick={()=> handleSubmit()
|
||||||
size: "large",
|
} type="submit" >{t("practical.submit")}</button>
|
||||||
}}
|
</div>
|
||||||
/>
|
</Form>
|
||||||
|
)
|
||||||
</Form>
|
}}
|
||||||
);
|
|
||||||
}}
|
</Formik>
|
||||||
</Formik>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,6 @@ export const useColumns = () => {
|
||||||
cloneValue[index] = {};
|
cloneValue[index] = {};
|
||||||
}
|
}
|
||||||
cloneValue[index][type] = !cloneValue[index][type];
|
cloneValue[index][type] = !cloneValue[index][type];
|
||||||
|
|
||||||
if(!cloneValue[index][type]){
|
|
||||||
cloneValue[index]["ALL"] = false
|
|
||||||
}
|
|
||||||
setValues(cloneValue)
|
setValues(cloneValue)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -28,22 +24,22 @@ export const useColumns = () => {
|
||||||
if(cloneValue[index]["ALL"]){
|
if(cloneValue[index]["ALL"]){
|
||||||
cloneValue[index] = {
|
cloneValue[index] = {
|
||||||
name:cloneValue[index]?.name ,
|
name:cloneValue[index]?.name ,
|
||||||
delete: typeof cloneValue[index]?.delete === "boolean" ? false : "disabled" ,
|
delete: false,
|
||||||
index: typeof cloneValue[index]?.index === "boolean" ? false : "disabled" ,
|
index: false,
|
||||||
show: typeof cloneValue[index]?.show === "boolean" ? false : "disabled" ,
|
show: false,
|
||||||
store: typeof cloneValue[index]?.store === "boolean" ? false : "disabled" ,
|
store: false,
|
||||||
update: typeof cloneValue[index]?.update === "boolean" ? false : "disabled" ,
|
update: false,
|
||||||
ALL: false
|
ALL: false
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
cloneValue[index] = {
|
cloneValue[index] = {
|
||||||
name:cloneValue[index]?.name ,
|
name:cloneValue[index]?.name ,
|
||||||
delete: typeof cloneValue[index]?.delete === "boolean" ? true : "disabled" ,
|
delete: true,
|
||||||
index: typeof cloneValue[index]?.index === "boolean" ? true : "disabled" ,
|
index: true,
|
||||||
show: typeof cloneValue[index]?.show === "boolean" ? true : "disabled" ,
|
show: true,
|
||||||
store: typeof cloneValue[index]?.store === "boolean" ? true : "disabled" ,
|
store: true,
|
||||||
update: typeof cloneValue[index]?.update === "boolean" ? true : "disabled" ,
|
update: true,
|
||||||
ALL: true
|
ALL: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,10 +57,11 @@ setValues(cloneValue)
|
||||||
|
|
||||||
|
|
||||||
const CheckBoxField = ({record,type,index}:{record:any,type:string,index:number})=>{
|
const CheckBoxField = ({record,type,index}:{record:any,type:string,index:number})=>{
|
||||||
|
|
||||||
|
|
||||||
|
const isChecked = record?.[type] ;
|
||||||
|
|
||||||
const isChecked = record?.[type] === true ;
|
return <Checkbox onChange={()=>onChange(type,index)} checked={isChecked} />;
|
||||||
const isDisabled = record?.[type] === "disabled" ;
|
|
||||||
return <Checkbox onChange={()=>onChange(type,index)} checked={isChecked} disabled={isDisabled} />;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -74,31 +71,11 @@ setValues(cloneValue)
|
||||||
return !!item?.index && !!item?.show && !!item?.store && !!item?.update && !!item?.delete
|
return !!item?.index && !!item?.show && !!item?.store && !!item?.update && !!item?.delete
|
||||||
})
|
})
|
||||||
const onChangeAllPermissions = ()=>{
|
const onChangeAllPermissions = ()=>{
|
||||||
const newShape =cloneValue?.map((item:any,index:number)=>{
|
const newShape =cloneValue?.map((item:any)=>{
|
||||||
if(IsAllValuesTrue){
|
if(IsAllValuesTrue){
|
||||||
console.log(item);
|
return {...item,delete: false,index: false,show: false,store: false,update: false,ALL: false}
|
||||||
|
}else{
|
||||||
return {
|
return {...item,delete: true,index: true,show: true,store: true,update: true,ALL: true}
|
||||||
...item,
|
|
||||||
delete: typeof item?.delete === "boolean" ? false : "disabled",
|
|
||||||
index: typeof item?.index === "boolean" ? false : "disabled",
|
|
||||||
show: typeof item?.show === "boolean" ? false : "disabled",
|
|
||||||
store: typeof item?.store === "boolean" ? false : "disabled",
|
|
||||||
update: typeof item?.update === "boolean" ? false : "disabled",
|
|
||||||
ALL: false
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
console.log(item);
|
|
||||||
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
delete: typeof item?.delete === "boolean" ? true : "disabled",
|
|
||||||
index: typeof item?.index === "boolean" ? true : "disabled",
|
|
||||||
show: typeof item?.show === "boolean" ? true : "disabled",
|
|
||||||
store: typeof item?.store === "boolean" ? true : "disabled",
|
|
||||||
update: typeof item?.update === "boolean" ? true : "disabled",
|
|
||||||
ALL: true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
setValues(newShape)
|
setValues(newShape)
|
||||||
|
|
@ -106,6 +83,8 @@ setValues(cloneValue)
|
||||||
|
|
||||||
return <Checkbox onChange={()=>onChangeAllPermissions()} checked={IsAllValuesTrue} />;
|
return <Checkbox onChange={()=>onChangeAllPermissions()} checked={IsAllValuesTrue} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const columns: TableColumnsType<any> = [
|
const columns: TableColumnsType<any> = [
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
@ -113,9 +92,6 @@ setValues(cloneValue)
|
||||||
dataIndex: "name",
|
dataIndex: "name",
|
||||||
key: "name",
|
key: "name",
|
||||||
align: "center",
|
align: "center",
|
||||||
render: (_text,record,index) => {
|
|
||||||
return ( <> {t(`models.${record?.name}`)} </> );
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("columns.add"),
|
title: t("columns.add"),
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,12 @@ export const useColumns = () => {
|
||||||
key: "name",
|
key: "name",
|
||||||
align: "center",
|
align: "center",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t("columns.created_at"),
|
||||||
|
dataIndex: "created_at",
|
||||||
|
key: "created_at",
|
||||||
|
align: "center",
|
||||||
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: t("columns.procedure"),
|
title: t("columns.procedure"),
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,16 @@
|
||||||
import React, { useState } from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import MathMLPreview from "./MathMLPreview";
|
import MathMLPreview from "./MathMLPreview";
|
||||||
import { Field, Form, Formik } from "formik";
|
|
||||||
import Test from "./Test";
|
|
||||||
import MarkdownPreview from '@uiw/react-markdown-preview';
|
|
||||||
import { BlockMath } from "react-katex";
|
|
||||||
|
|
||||||
const Dummy = () => {
|
const Dummy = () => {
|
||||||
const [t] = useTranslation();
|
const [t] = useTranslation();
|
||||||
const [markdown, setMarkdown] = useState<string>(' \nV_{sphere} = \\frac{4}{3}\\pi r^3\n');
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="DummyHomePage">
|
<div className="DummyHomePage">
|
||||||
|
|
||||||
<MarkdownPreview style={{background:"transparent" ,color:"black"}} source={"This is an <u>underlined</u> text."} />
|
<MathMLPreview/>
|
||||||
<BlockMath>
|
|
||||||
{markdown}
|
|
||||||
</BlockMath>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
import { Input } from 'antd';
|
|
||||||
import React, { useState } from 'react'
|
|
||||||
|
|
||||||
const Test = React.memo(
|
|
||||||
({field,form}:{field:any,form:any}) => {
|
|
||||||
const name = field.name ;
|
|
||||||
const {setFieldValue,getFieldProps} = form
|
|
||||||
console.log(name);
|
|
||||||
const value = getFieldProps(`${name}`).value
|
|
||||||
const [CurrentValue, setCurrentValue] = useState(value)
|
|
||||||
const handleChange=(e: React.ChangeEvent<HTMLInputElement>)=>{
|
|
||||||
setCurrentValue(e.target.value)
|
|
||||||
}
|
|
||||||
const onBlur=()=>{
|
|
||||||
setFieldValue(`${name}`,CurrentValue)
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Input onChange={(e)=>handleChange(e)} value={CurrentValue} type="text" name="" id="" onBlur={onBlur} />
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
},(prevProps:any,nextProps:any)=>{
|
|
||||||
const prevValue = prevProps.field.value;
|
|
||||||
const nextValue = nextProps.field.value;
|
|
||||||
|
|
||||||
return prevValue === nextValue
|
|
||||||
})
|
|
||||||
|
|
||||||
export default Test
|
|
||||||
|
|
@ -68,7 +68,7 @@ console.log(PackagesInfo);
|
||||||
</div>
|
</div>
|
||||||
<button
|
<button
|
||||||
className="add_button"
|
className="add_button"
|
||||||
disabled={status === QueryStatusEnum.LOADING || !formik.dirty || !values?.package_id}
|
disabled={status === QueryStatusEnum.LOADING || !formik.dirty}
|
||||||
onClick={handleNext}
|
onClick={handleNext}
|
||||||
>
|
>
|
||||||
{t(`practical.sale`)}
|
{t(`practical.sale`)}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ const Form = ({status}:{status?:any}) => {
|
||||||
const {values,setFieldValue} = useFormikContext<any>()
|
const {values,setFieldValue} = useFormikContext<any>()
|
||||||
console.log(values?.currentModalIndex);
|
console.log(values?.currentModalIndex);
|
||||||
const { isOpen, setIsOpen } = useModalState((state) => state);
|
const { isOpen, setIsOpen } = useModalState((state) => state);
|
||||||
const { setObjectToEdit,objectToEdit } = useObjectToEdit();
|
const { setObjectToEdit } = useObjectToEdit();
|
||||||
const {t} = useTranslation();
|
const {t} = useTranslation();
|
||||||
const formik = useFormikContext();
|
const formik = useFormikContext();
|
||||||
const handleNext = ()=>{
|
const handleNext = ()=>{
|
||||||
|
|
@ -27,14 +27,6 @@ const Form = ({status}:{status?:any}) => {
|
||||||
setObjectToEdit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const student_info = objectToEdit?.data?.data
|
|
||||||
const PackagesInfo = student_info?.packages.map((info:any) => ({
|
|
||||||
id: info?.id,
|
|
||||||
name: info.name + " " + `( ${info?.original_price} )`
|
|
||||||
}));
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
values?.currentModalIndex == 2 &&
|
values?.currentModalIndex == 2 &&
|
||||||
|
|
||||||
|
|
@ -57,11 +49,9 @@ const Form = ({status}:{status?:any}) => {
|
||||||
<ValidationField
|
<ValidationField
|
||||||
placeholder="choose"
|
placeholder="choose"
|
||||||
label="package"
|
label="package"
|
||||||
name="package_id"
|
name="package"
|
||||||
type="Select"
|
type="Select"
|
||||||
option={PackagesInfo}
|
option={[]}
|
||||||
disabled
|
|
||||||
allowClear={false}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/* {values?.currentModalIndex} */}
|
{/* {values?.currentModalIndex} */}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ const Form = () => {
|
||||||
const {data,isError,isSuccess,status} = useGetStudentByPhone({
|
const {data,isError,isSuccess,status} = useGetStudentByPhone({
|
||||||
phone_number:phoneNumber
|
phone_number:phoneNumber
|
||||||
},{
|
},{
|
||||||
enabled: triggerApi
|
enabled: triggerApi
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleNext = ()=>{
|
const handleNext = ()=>{
|
||||||
|
|
@ -38,11 +38,9 @@ const Form = () => {
|
||||||
setIsOpen("");
|
setIsOpen("");
|
||||||
setObjectToEdit({});
|
setObjectToEdit({});
|
||||||
};
|
};
|
||||||
console.log(data?.data);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if(isSuccess == true){
|
||||||
if(!!data?.data?.phone_number){
|
|
||||||
setFieldValue( "currentModalIndex" , values?.currentModalIndex + 1 )
|
setFieldValue( "currentModalIndex" , values?.currentModalIndex + 1 )
|
||||||
setObjectToEdit({data})
|
setObjectToEdit({data})
|
||||||
setTriggerApi(false)
|
setTriggerApi(false)
|
||||||
|
|
@ -53,7 +51,7 @@ const Form = () => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [data?.data])
|
}, [isSuccess])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { TCrudRoute, TMenuItem } from "./types/App";
|
import { TCrudRoute, TMenuItem } from "./types/App";
|
||||||
import { FaCashRegister, FaCity, FaHome, FaMoneyBill, FaPaperclip, FaSellcast, FaTag, FaUser, FaUserShield } from "react-icons/fa";
|
import { FaCashRegister, FaHome, FaMoneyBill, FaPaperclip, FaSellcast, FaTag, FaUser, FaUserShield } from "react-icons/fa";
|
||||||
import { GoDotFill } from "react-icons/go";
|
import { GoDotFill } from "react-icons/go";
|
||||||
import { MdOutlineSell } from "react-icons/md";
|
import { MdOutlineSell } from "react-icons/md";
|
||||||
import { CgProfile } from "react-icons/cg";
|
import { CgProfile } from "react-icons/cg";
|
||||||
|
|
@ -9,9 +9,7 @@ import React from "react";
|
||||||
const Dummy = React.lazy(() => import("./Pages/Home/Dummy"));
|
const Dummy = React.lazy(() => import("./Pages/Home/Dummy"));
|
||||||
|
|
||||||
const Grade = React.lazy(() => import("./Pages/Admin/Grade/Page"));
|
const Grade = React.lazy(() => import("./Pages/Admin/Grade/Page"));
|
||||||
const City = React.lazy(() => import("./Pages/Admin/City/Page"));
|
const Curriculum = React.lazy(() => import("./Pages/Admin/Curriculum/Page"));
|
||||||
const Area = React.lazy(() => import("./Pages/Admin/Area/Page"));
|
|
||||||
|
|
||||||
const Subject = React.lazy(() => import("./Pages/Admin/subject/Table/Page"));
|
const Subject = React.lazy(() => import("./Pages/Admin/subject/Table/Page"));
|
||||||
const Tags = React.lazy(() => import("./Pages/Admin/Tags/Page"));
|
const Tags = React.lazy(() => import("./Pages/Admin/Tags/Page"));
|
||||||
const Unit = React.lazy(() => import("./Pages/Admin/Unit/Page"));
|
const Unit = React.lazy(() => import("./Pages/Admin/Unit/Page"));
|
||||||
|
|
@ -137,19 +135,7 @@ export const menuItems: TMenuItem[] = [
|
||||||
abilities: ABILITIES_ENUM?.RE_SELLER,
|
abilities: ABILITIES_ENUM?.RE_SELLER,
|
||||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
||||||
prevPath: 0,
|
prevPath: 0,
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
header: "page_header.city",
|
|
||||||
element: <City />,
|
|
||||||
icon: <FaCity />,
|
|
||||||
text: "sidebar.city",
|
|
||||||
path: `/${ABILITIES_ENUM?.CITY}`,
|
|
||||||
abilities: ABILITIES_ENUM?.CITY,
|
|
||||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
|
||||||
prevPath: 0,
|
|
||||||
},
|
|
||||||
|
|
||||||
// {
|
// {
|
||||||
// header: "page_header.report",
|
// header: "page_header.report",
|
||||||
// element: <Report />,
|
// element: <Report />,
|
||||||
|
|
@ -372,15 +358,6 @@ export const CrudRoute: TCrudRoute[] = [
|
||||||
prevPath: 0,
|
prevPath: 0,
|
||||||
type: UserTypeEnum.RE_SELLER,
|
type: UserTypeEnum.RE_SELLER,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
header: "page_header.Area",
|
|
||||||
element: <Area />,
|
|
||||||
path: `/${ABILITIES_ENUM?.CITY}/:${ParamsEnum?.CITY_ID}`,
|
|
||||||
abilities: ABILITIES_ENUM?.AREA,
|
|
||||||
abilities_value: ABILITIES_VALUES_ENUM.INDEX,
|
|
||||||
prevPath: 1,
|
|
||||||
},
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|
||||||
export const AppRoutes: Record<string, string> = Object.fromEntries(
|
export const AppRoutes: Record<string, string> = Object.fromEntries(
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,4 @@
|
||||||
|
|
||||||
.PageTitleLastItem {
|
.PageTitleLastItem {
|
||||||
color: #202C4B !important;
|
color: #202C4B !important;
|
||||||
}
|
|
||||||
|
|
||||||
.permissions_submit_button{
|
|
||||||
transform: translateY(-40px);
|
|
||||||
}
|
}
|
||||||
|
|
@ -83,24 +83,3 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.MapField{
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
flex-direction: column;
|
|
||||||
min-height: 400px;
|
|
||||||
|
|
||||||
}
|
|
||||||
.AttachmentFormBody{
|
|
||||||
display: flex;
|
|
||||||
margin-top: 20px;
|
|
||||||
padding-left: 50px;
|
|
||||||
.ImageBoxField{
|
|
||||||
min-width: 200px;
|
|
||||||
}
|
|
||||||
|
|
||||||
>*{
|
|
||||||
min-width: 50%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import useAddMutation from "./helper/useAddMutation";
|
|
||||||
import useDeleteMutation from "./helper/useDeleteMutation";
|
|
||||||
import useGetQuery from "./helper/useGetQuery";
|
|
||||||
import useUpdateMutation from "./helper/useUpdateMutation";
|
|
||||||
|
|
||||||
const API = {
|
|
||||||
GET: "/ability",
|
|
||||||
ADD: "/ability",
|
|
||||||
DELETE: "/ability",
|
|
||||||
UPDATE: "/ability",
|
|
||||||
};
|
|
||||||
|
|
||||||
const KEY = "ability";
|
|
||||||
|
|
||||||
export const useGetAllAbility = (params?: any, options?: any) =>
|
|
||||||
useGetQuery(KEY, API.GET, params, options);
|
|
||||||
export const useAddAbility = () => useAddMutation(KEY, API.ADD);
|
|
||||||
export const useUpdateAbility = (params?: any) =>
|
|
||||||
useUpdateMutation(KEY, API.GET);
|
|
||||||
export const useDeleteAbility = (params?: any) =>
|
|
||||||
useDeleteMutation(KEY, API.DELETE);
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import useAddMutation from "./helper/useAddMutation";
|
|
||||||
import useDeleteMutation from "./helper/useDeleteMutation";
|
|
||||||
import useGetQuery from "./helper/useGetQuery";
|
|
||||||
import useUpdateMutation from "./helper/useUpdateMutation";
|
|
||||||
|
|
||||||
const API = {
|
|
||||||
GET: "/area",
|
|
||||||
ADD: "/area",
|
|
||||||
DELETE: "/area",
|
|
||||||
UPDATE: "/area",
|
|
||||||
};
|
|
||||||
|
|
||||||
const KEY = "Area";
|
|
||||||
|
|
||||||
export const useGetAllArea = (params?: any, options?: any) =>
|
|
||||||
useGetQuery(KEY, API.GET, params, options);
|
|
||||||
export const useAddArea = () => useAddMutation(KEY, API.ADD);
|
|
||||||
export const useUpdateArea = (params?: any) => useUpdateMutation(KEY, API.GET);
|
|
||||||
export const useDeleteArea = (params?: any) =>
|
|
||||||
useDeleteMutation(KEY, API.DELETE);
|
|
||||||
|
|
@ -1,20 +0,0 @@
|
||||||
import useAddMutation from "./helper/useAddMutation";
|
|
||||||
import useDeleteMutation from "./helper/useDeleteMutation";
|
|
||||||
import useGetQuery from "./helper/useGetQuery";
|
|
||||||
import useUpdateMutation from "./helper/useUpdateMutation";
|
|
||||||
|
|
||||||
const API = {
|
|
||||||
GET: "/city",
|
|
||||||
ADD: "/city",
|
|
||||||
DELETE: "/city",
|
|
||||||
UPDATE: "/city",
|
|
||||||
};
|
|
||||||
|
|
||||||
const KEY = "city";
|
|
||||||
|
|
||||||
export const useGetAllCity = (params?: any, options?: any) =>
|
|
||||||
useGetQuery(KEY, API.GET, params, options);
|
|
||||||
export const useAddCity = () => useAddMutation(KEY, API.ADD);
|
|
||||||
export const useUpdateCity = (params?: any) => useUpdateMutation(KEY, API.GET);
|
|
||||||
export const useDeleteCity = (params?: any) =>
|
|
||||||
useDeleteMutation(KEY, API.DELETE);
|
|
||||||
|
|
@ -4,13 +4,13 @@ import useGetQuery from "./helper/useGetQuery";
|
||||||
import useUpdateMutation from "./helper/useUpdateMutation";
|
import useUpdateMutation from "./helper/useUpdateMutation";
|
||||||
|
|
||||||
const API = {
|
const API = {
|
||||||
GET: "/permission",
|
GET: "/permissions",
|
||||||
ADD: "/permission",
|
ADD: "/permissions",
|
||||||
DELETE: "/permission",
|
DELETE: "/permissions",
|
||||||
UPDATE: "/permission",
|
UPDATE: "/permissions",
|
||||||
};
|
};
|
||||||
|
|
||||||
const KEY = "Permission";
|
const KEY = "Permissions";
|
||||||
|
|
||||||
export const useGetAllPermissions = (params?: any, options?: any) =>
|
export const useGetAllPermissions = (params?: any, options?: any) =>
|
||||||
useGetQuery(KEY, API.GET, params, options);
|
useGetQuery(KEY, API.GET, params, options);
|
||||||
|
|
|
||||||
|
|
@ -211,20 +211,6 @@ export enum ModalEnum {
|
||||||
PERMISSION_ADD = "PERMISSION.add",
|
PERMISSION_ADD = "PERMISSION.add",
|
||||||
PERMISSION_DELETE = "PERMISSION.delete",
|
PERMISSION_DELETE = "PERMISSION.delete",
|
||||||
|
|
||||||
/// CITY
|
|
||||||
|
|
||||||
CITY_EDIT = "CITY.edit",
|
|
||||||
CITY_ADD = "CITY.add",
|
|
||||||
CITY_DELETE = "CITY.delete",
|
|
||||||
|
|
||||||
|
|
||||||
/// AREA
|
|
||||||
|
|
||||||
AREA_EDIT = "AREA.edit",
|
|
||||||
AREA_ADD = "AREA.add",
|
|
||||||
AREA_DELETE = "AREA.delete",
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// sales
|
/// sales
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,9 +58,7 @@ export enum ABILITIES_ENUM {
|
||||||
Collections = "collections",
|
Collections = "collections",
|
||||||
SETTING = "setting",
|
SETTING = "setting",
|
||||||
Email = "email",
|
Email = "email",
|
||||||
Phone = "phone",
|
Phone = "phone"
|
||||||
CITY = "city",
|
|
||||||
AREA = "area"
|
|
||||||
////
|
////
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -13,5 +13,4 @@ export enum ParamsEnum {
|
||||||
CHILDREN_QUESTION_ID = "children_question_id",
|
CHILDREN_QUESTION_ID = "children_question_id",
|
||||||
RE_SELLER_ID = "re_seller_id",
|
RE_SELLER_ID = "re_seller_id",
|
||||||
ROLE_ID = "role_id",
|
ROLE_ID = "role_id",
|
||||||
CITY_ID = "city_id",
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -310,9 +310,6 @@
|
||||||
"This will close your account. Your account will be interactive when you log in again":"سيؤدي هذا إلى إغلاق حسابك. سيكون حسابك تفاعليا عند تسجيل الدخول مرة أخرى",
|
"This will close your account. Your account will be interactive when you log in again":"سيؤدي هذا إلى إغلاق حسابك. سيكون حسابك تفاعليا عند تسجيل الدخول مرة أخرى",
|
||||||
"Your account will be permanently deleted":"سيتم حذف حسابك نهائيا",
|
"Your account will be permanently deleted":"سيتم حذف حسابك نهائيا",
|
||||||
"search":"بحث",
|
"search":"بحث",
|
||||||
"Map":"الخريطة",
|
|
||||||
"Show":"عرض",
|
|
||||||
"Hide":"اخفاء",
|
|
||||||
"sale":"بيع"
|
"sale":"بيع"
|
||||||
},
|
},
|
||||||
"Table": {
|
"Table": {
|
||||||
|
|
@ -395,14 +392,6 @@
|
||||||
"collections": "التحصيلات",
|
"collections": "التحصيلات",
|
||||||
"phone_number":"رقم الهاتف",
|
"phone_number":"رقم الهاتف",
|
||||||
"email_address":"عنوان البريد الإلكتروني",
|
"email_address":"عنوان البريد الإلكتروني",
|
||||||
"ability": "القدرات",
|
|
||||||
"answer": "إجابة",
|
|
||||||
"area": "منطقة",
|
|
||||||
"coupon": "قسيمة",
|
|
||||||
"package": "حزمة",
|
|
||||||
"packageItem": "عنصر الحزمة",
|
|
||||||
"Area":"المنطقة",
|
|
||||||
"City":"مدينة",
|
|
||||||
"add_sales":"إضافة عملية بيع",
|
"add_sales":"إضافة عملية بيع",
|
||||||
"are_you_sure_about_sale":"هل أنت متأكد من عملية البيع ؟"
|
"are_you_sure_about_sale":"هل أنت متأكد من عملية البيع ؟"
|
||||||
},
|
},
|
||||||
|
|
@ -873,9 +862,7 @@
|
||||||
"users":"المستخدمون",
|
"users":"المستخدمون",
|
||||||
"managers":"مدراء",
|
"managers":"مدراء",
|
||||||
"sales":"المبيعات",
|
"sales":"المبيعات",
|
||||||
"collections": "التحصيلات",
|
"collections": "التحصيلات"
|
||||||
"Area":"المنطقة",
|
|
||||||
"city":"مدينة"
|
|
||||||
},
|
},
|
||||||
"message": {
|
"message": {
|
||||||
"some_thing_went_wrong": "حدث خطأ ما",
|
"some_thing_went_wrong": "حدث خطأ ما",
|
||||||
|
|
@ -921,8 +908,6 @@
|
||||||
"collections": "التحصيلات",
|
"collections": "التحصيلات",
|
||||||
"sales":"المبيعات",
|
"sales":"المبيعات",
|
||||||
"edit_manager":"تعديل مدير",
|
"edit_manager":"تعديل مدير",
|
||||||
"City":"مدينة",
|
|
||||||
"Area":"المنطقة",
|
|
||||||
"setting":"الإعدادات",
|
"setting":"الإعدادات",
|
||||||
"edit_reseller":"تعديل البائع"
|
"edit_reseller":"تعديل البائع"
|
||||||
},
|
},
|
||||||
|
|
@ -971,9 +956,7 @@
|
||||||
"managers":"مدراء",
|
"managers":"مدراء",
|
||||||
"collections": "التحصيلات",
|
"collections": "التحصيلات",
|
||||||
"sales":"المبيعات",
|
"sales":"المبيعات",
|
||||||
"setting":"الإعدادات",
|
"setting":"الإعدادات"
|
||||||
"City":"مدينة",
|
|
||||||
"Area":"المنطقة"
|
|
||||||
},
|
},
|
||||||
"table": {
|
"table": {
|
||||||
"student": "قائمة الطلاب",
|
"student": "قائمة الطلاب",
|
||||||
|
|
@ -988,8 +971,6 @@
|
||||||
"setting":"الإعدادات",
|
"setting":"الإعدادات",
|
||||||
"file_setting":"إعدادات الملف",
|
"file_setting":"إعدادات الملف",
|
||||||
"security_setting":"إعدادات الأمان",
|
"security_setting":"إعدادات الأمان",
|
||||||
"Area":"المنطقة",
|
|
||||||
"City":"مدينة",
|
|
||||||
"notification":"الاشعارات",
|
"notification":"الاشعارات",
|
||||||
"upload_your_photo_and_personal_data_here":"قم بتحميل صورتك وبياناتك الشخصية هنا",
|
"upload_your_photo_and_personal_data_here":"قم بتحميل صورتك وبياناتك الشخصية هنا",
|
||||||
"get_notified_of_whats_happening_now_you_can_turn_it_off_at_any_time":"احصل على إشعار بما يحدث الآن ، يمكنك إيقاف تشغيله في أي وقت"
|
"get_notified_of_whats_happening_now_you_can_turn_it_off_at_any_time":"احصل على إشعار بما يحدث الآن ، يمكنك إيقاف تشغيله في أي وقت"
|
||||||
|
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import { Nullable } from "./App";
|
|
||||||
|
|
||||||
// Define the Teacher interface
|
|
||||||
|
|
||||||
export interface Area {
|
|
||||||
id: number; // Unique identifier for the user
|
|
||||||
name: string; // Name of the user
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InitialValues {
|
|
||||||
id: number; // Unique identifier for the user
|
|
||||||
name: string; // Name of the user
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export type AreaInitialValues = Partial<Nullable<InitialValues>>;
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
import { Nullable } from "./App";
|
|
||||||
|
|
||||||
// Define the Teacher interface
|
|
||||||
|
|
||||||
export interface City {
|
|
||||||
id: number; // Unique identifier for the user
|
|
||||||
name: string; // Name of the user
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface InitialValues {
|
|
||||||
id: number; // Unique identifier for the user
|
|
||||||
name: string; // Name of the user
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export type CityInitialValues = Partial<Nullable<InitialValues>>;
|
|
||||||
|
|
@ -24,57 +24,6 @@ export const canIndexEduClass = hasAbility(
|
||||||
ABILITIES_VALUES_ENUM.INDEX,
|
ABILITIES_VALUES_ENUM.INDEX,
|
||||||
);
|
);
|
||||||
|
|
||||||
///// City
|
|
||||||
|
|
||||||
export const canAddCity = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.STORE,
|
|
||||||
);
|
|
||||||
export const canEditCity = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.UPDATE,
|
|
||||||
);
|
|
||||||
export const canDeleteCity = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.DELETE,
|
|
||||||
);
|
|
||||||
export const canShowCity = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.SHOW,
|
|
||||||
);
|
|
||||||
export const canIndexCity = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.INDEX,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
///// Area
|
|
||||||
|
|
||||||
export const canAddArea = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.STORE,
|
|
||||||
);
|
|
||||||
export const canEditArea = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.UPDATE,
|
|
||||||
);
|
|
||||||
export const canDeleteArea = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.DELETE,
|
|
||||||
);
|
|
||||||
export const canShowArea = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.SHOW,
|
|
||||||
);
|
|
||||||
export const canIndexArea = hasAbility(
|
|
||||||
ABILITIES_ENUM.EDUCATION_CLASS,
|
|
||||||
ABILITIES_VALUES_ENUM.INDEX,
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///// Course
|
///// Course
|
||||||
|
|
||||||
export const canAddCourse = hasAbility(
|
export const canAddCourse = hasAbility(
|
||||||
|
|
@ -324,6 +273,15 @@ export const canShowStudent = hasAbility(
|
||||||
ABILITIES_VALUES_ENUM.SHOW,
|
ABILITIES_VALUES_ENUM.SHOW,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const canImportStudent = hasAbility(
|
||||||
|
ABILITIES_ENUM.STUDENT,
|
||||||
|
ABILITIES_VALUES_ENUM.IMPORT_STUDENTS,
|
||||||
|
);
|
||||||
|
export const canMoveStudent = hasAbility(
|
||||||
|
ABILITIES_ENUM.STUDENT,
|
||||||
|
ABILITIES_VALUES_ENUM.MOVE_STUDENTS,
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/// Manager
|
/// Manager
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user