added enter/exit columns to operator violations

This commit is contained in:
2026-07-12 11:39:39 +03:30
parent 51afdd47a0
commit 1680cb44b7
2 changed files with 68 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ import ViolationsList from "./ViolationsList";
const ViolationsDialog = ({ open, setOpen, mutate }) => {
return (
<Dialog open={open} fullWidth maxWidth="xs">
<Dialog open={open} fullWidth maxWidth="sm">
<IconButton
aria-label="close"
onClick={() => setOpen(false)}

View File

@@ -116,6 +116,54 @@ const ViolationsList = ({ setOpen, mutate }) => {
},
Cell: ({ row }) => <>{row.original.city_name}</>,
},
{
accessorKey: "enter_time",
header: "تاریخ و ساعت ورود",
id: "enter_time",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 140,
Cell: ({ cell }) => {
const value = formatDateTime(cell.getValue());
if (!value) return "-";
return (
<>
<span className="font-medium">{value.date}</span>
<span> - </span>
<span className="text-xs text-muted-foreground">{value.time}</span>
</>
);
},
},
{
accessorKey: "exit_time",
header: "تاریخ و ساعت خروج",
id: "exit_time",
enableColumnFilter: true,
datatype: "text",
filterMode: "equals",
columnFilterModeOptions: ["equals", "contains"],
grow: false,
size: 140,
Cell: ({ cell }) => {
const value = formatDateTime(cell.getValue());
if (!value) return "-";
return (
<div className="flex flex-col leading-tight">
<span className="font-medium">{value.date}</span>
<span> - </span>
<span className="text-xs text-muted-foreground">{value.time}</span>
</div>
);
},
},
];
}, []);
@@ -139,3 +187,22 @@ const ViolationsList = ({ setOpen, mutate }) => {
);
};
export default ViolationsList;
const formatDateTime = (value) => {
if (!value) return null;
const date = new Date(value.replace(" ", "T"));
return {
date: new Intl.DateTimeFormat("fa-IR", {
year: "numeric",
month: "2-digit",
day: "2-digit",
}).format(date),
time: new Intl.DateTimeFormat("fa-IR", {
hour: "2-digit",
minute: "2-digit",
}).format(date),
};
};