Feature/gasht cartables
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
"use client";
|
||||
import { useMemo } from "react";
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { Box, Stack, Typography } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import Toolbar from "./Toolbar";
|
||||
import { GET_ROAD_PATROL_OPERATOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import ReportForm from "./RowActions/ReportForm";
|
||||
|
||||
const OperatorList = () => {
|
||||
const columns = useMemo(
|
||||
@@ -81,6 +82,29 @@ const OperatorList = () => {
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
header: "گزارش مامور",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ renderedCellValue, row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ReportForm rowId={row.getValue("id")} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -89,7 +113,6 @@ const OperatorList = () => {
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
table_title={"عملیات"}
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
sorting={[{ id: "id", desc: true }]}
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Tooltip, IconButton } from "@mui/material";
|
||||
import PrintIcon from "@mui/icons-material/Print";
|
||||
|
||||
const ReportForm = ({ rowId }) => {
|
||||
const reportUrl = "https://rms.rmto.ir/v2/road_patrols/operator/report/96872"; // TODO replace id here
|
||||
|
||||
const reportUrl = `https://rms.rmto.ir/v2/road_patrols/operator/report/${rowId}`;
|
||||
return (
|
||||
<Tooltip title="گزارش" arrow placement="right">
|
||||
<IconButton
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ReportForm from "./ReportForm";
|
||||
|
||||
const RowActions = ({ row }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<ReportForm rowId={row.getValue("id")} />
|
||||
</Box>
|
||||
);
|
||||
return <Box sx={{ display: "flex", gap: 1 }}></Box>;
|
||||
};
|
||||
export default RowActions;
|
||||
|
||||
@@ -1,9 +1,45 @@
|
||||
import { Button, DialogActions, DialogContent, Stack, Typography, List, ListItem } from "@mui/material";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import React from "react";
|
||||
import React, { useState } from "react";
|
||||
import { DELETE_ROAD_PATROL_SUPERVISOR } from "@/core/utils/routes";
|
||||
|
||||
const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
||||
const requestServer = useRequest();
|
||||
const requestServer = useRequest({ notificationSuccess: true });
|
||||
const [submittingPartial, setSubmittingPartial] = useState(false);
|
||||
const [submittingGeneral, setSubmittingGeneral] = useState(false);
|
||||
const handleGeneralDelete = () => {
|
||||
setSubmittingGeneral(true);
|
||||
requestServer(`${DELETE_ROAD_PATROL_SUPERVISOR}/${rowId}`, "post", {
|
||||
data: {
|
||||
type: 2,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpenDeleteDialog(false);
|
||||
setSubmittingGeneral(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmittingGeneral(false);
|
||||
});
|
||||
};
|
||||
|
||||
const handlePartialDelete = () => {
|
||||
setSubmittingPartial(true);
|
||||
requestServer(`${DELETE_ROAD_PATROL_SUPERVISOR}/${rowId}`, "post", {
|
||||
data: {
|
||||
type: 1,
|
||||
},
|
||||
})
|
||||
.then(() => {
|
||||
mutate();
|
||||
setOpenDeleteDialog(false);
|
||||
setSubmittingPartial(false);
|
||||
})
|
||||
.catch(() => {
|
||||
setSubmittingPartial(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -42,23 +78,11 @@ const DeleteContent = ({ rowId, mutate, setOpenDeleteDialog }) => {
|
||||
<Button onClick={() => setOpenDeleteDialog(false)} variant="outlined" color="primary">
|
||||
بستن
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
/* handle partial delete */
|
||||
}}
|
||||
variant="outlined"
|
||||
color="warning"
|
||||
>
|
||||
حذف جزئی
|
||||
<Button onClick={handlePartialDelete} variant="outlined" color="warning" disabled={submittingPartial}>
|
||||
{submittingPartial ? "درحال ارسال اطلاعات..." : "حذف جزئی"}
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => {
|
||||
/* handle complete delete */
|
||||
}}
|
||||
variant="contained"
|
||||
color="error"
|
||||
>
|
||||
حذف کلی
|
||||
<Button onClick={handleGeneralDelete} variant="contained" color="error" disabled={submittingGeneral}>
|
||||
{submittingGeneral ? "درحال ارسال اطلاعات..." : "حذف کلی"}
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</>
|
||||
|
||||
@@ -1,26 +1,10 @@
|
||||
import { Dialog, DialogContent, DialogTitle, IconButton, Tooltip, Typography, Card, CardContent } from "@mui/material";
|
||||
import { useState } from "react";
|
||||
import useRequest from "@/lib/hooks/useRequest";
|
||||
import RemoveRedEyeIcon from "@mui/icons-material/RemoveRedEye";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
|
||||
const OfficerDescriptionForm = ({ row }) => {
|
||||
const OfficerDescriptionForm = ({ description }) => {
|
||||
const [openOfficerDescriptionDialog, setOpenOfficerDescriptionDialog] = useState(false);
|
||||
const requestServer = useRequest();
|
||||
|
||||
const handleSubmit = () => {
|
||||
// requestServer(`${RESERVE_PASSENGER_BOSS}/${rowId}`, "post", { description })
|
||||
// .then((response) => {
|
||||
// setOpenOfficerDescriptionDialog(false);
|
||||
// mutate();
|
||||
// })
|
||||
// .catch((error) => {
|
||||
// console.error(error);
|
||||
// })
|
||||
// .finally(() => {
|
||||
// setIsSubmitting(false);
|
||||
// });
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -55,18 +39,7 @@ const OfficerDescriptionForm = ({ row }) => {
|
||||
<DialogContent>
|
||||
<Card sx={{ padding: 2, boxShadow: 3, borderRadius: 2 }}>
|
||||
<CardContent>
|
||||
<Typography
|
||||
gutterBottom
|
||||
variant="body1"
|
||||
component="div"
|
||||
sx={{ fontWeight: "bold", mb: 2, color: "primary.main" }}
|
||||
>
|
||||
توضیحات :
|
||||
</Typography>
|
||||
<Typography variant="body2">
|
||||
{row.original.description || "هیچ توضیحی موجود نیست"}{" "}
|
||||
{/* should replace row.original.description with the back end*/}
|
||||
</Typography>
|
||||
<Typography variant="body2">{description || "هیچ توضیحی موجود نیست"} </Typography>
|
||||
</CardContent>
|
||||
</Card>
|
||||
</DialogContent>
|
||||
@@ -74,5 +47,4 @@ const OfficerDescriptionForm = ({ row }) => {
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default OfficerDescriptionForm;
|
||||
|
||||
@@ -2,8 +2,7 @@ import { Tooltip, IconButton } from "@mui/material";
|
||||
import PrintIcon from "@mui/icons-material/Print";
|
||||
|
||||
const ReportForm = ({ rowId }) => {
|
||||
const reportUrl = "https://rms.rmto.ir/v2/road_patrols/operator/report/96872"; // TODO replace id here
|
||||
|
||||
const reportUrl = `https://rms.rmto.ir/v2/road_patrols/operator/report/${rowId}`;
|
||||
return (
|
||||
<Tooltip title="گزارش" arrow placement="right">
|
||||
<IconButton
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import { Box } from "@mui/material";
|
||||
import ReportForm from "./ReportForm";
|
||||
import DeleteForm from "./DeleteForm";
|
||||
import OfficerDescriptionForm from "./OfficerDescription";
|
||||
|
||||
const RowActions = ({ row, mutate }) => {
|
||||
return (
|
||||
<Box sx={{ display: "flex", gap: 1 }}>
|
||||
<ReportForm rowId={row.getValue("id")} />
|
||||
<OfficerDescriptionForm row={row} />
|
||||
<DeleteForm rowId={row.getValue("id")} mutate={mutate} />
|
||||
</Box>
|
||||
);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
"use client";
|
||||
import { useMemo } from "react";
|
||||
import { Box, Typography } from "@mui/material";
|
||||
import { Box, Stack } from "@mui/material";
|
||||
import DataTableWithAuth from "@/core/components/DataTableWithAuth";
|
||||
import Toolbar from "./Toolbar";
|
||||
import { GET_ROAD_PATROL_SUPERVISOR_LIST } from "@/core/utils/routes";
|
||||
import moment from "jalali-moment";
|
||||
import RowActions from "./RowActions";
|
||||
import useProvinces from "@/lib/hooks/useProvince";
|
||||
import useRoadItemGetItems from "@/lib/hooks/useRoadItemGetItems";
|
||||
import CustomSelectByDependency from "@/core/components/DataTable/filter/fieldsType/CustomSelectByDependency";
|
||||
import useEdaratLists from "@/lib/hooks/useEdaratLists";
|
||||
import OfficerDescriptionForm from "./RowActions/OfficerDescription";
|
||||
import ReportForm from "./RowActions/ReportForm";
|
||||
|
||||
const OperatorList = () => {
|
||||
const columns = useMemo(
|
||||
@@ -151,6 +152,54 @@ const OperatorList = () => {
|
||||
grow: false,
|
||||
size: 100,
|
||||
},
|
||||
{
|
||||
accessorKey: "description",
|
||||
header: "توضیحات مامور",
|
||||
id: "description",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ renderedCellValue }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<OfficerDescriptionForm description={renderedCellValue} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
{
|
||||
header: "گزارش مامور",
|
||||
enableColumnFilter: false,
|
||||
datatype: "text",
|
||||
grow: false,
|
||||
size: 100,
|
||||
muiTableBodyCellProps: {
|
||||
sx: {
|
||||
borderLeft: "1px solid #e1e1e1",
|
||||
py: 0,
|
||||
"&:first-of-type": {
|
||||
borderLeft: "unset",
|
||||
},
|
||||
},
|
||||
},
|
||||
Cell: ({ renderedCellValue, row }) => {
|
||||
return (
|
||||
<Stack alignItems={"center"} justifyContent={"center"}>
|
||||
<ReportForm rowId={row.getValue("id")} />
|
||||
</Stack>
|
||||
);
|
||||
},
|
||||
},
|
||||
],
|
||||
[]
|
||||
);
|
||||
@@ -159,7 +208,6 @@ const OperatorList = () => {
|
||||
<>
|
||||
<Box sx={{ p: 1, border: 1, borderColor: "divider", borderRadius: 1 }}>
|
||||
<DataTableWithAuth
|
||||
table_title={"ارزیابی"}
|
||||
need_filter={true}
|
||||
columns={columns}
|
||||
sorting={[{ id: "id", desc: true }]}
|
||||
|
||||
Reference in New Issue
Block a user