;
+ const selectedIds = Array.from(idsSet).map(
+ (id: string | number) => String(id)
+ );
+ setIds(selectedIds);
+ } else {
+ setIds([]);
+ }
+ }
+ : undefined
+ }
localeText={ruRU.components.MuiDataGrid.defaultProps.localeText}
slots={{
noRowsOverlay: () => (
diff --git a/src/pages/Route/LinekedStations.tsx b/src/pages/Route/LinekedStations.tsx
index 814af4b..4d9fd71 100644
--- a/src/pages/Route/LinekedStations.tsx
+++ b/src/pages/Route/LinekedStations.tsx
@@ -252,7 +252,7 @@ const LinkedItemsContentsInner = <
})
.catch((error) => {
console.error("Error fetching all items:", error);
- setError("Failed to load available stations");
+ setError(null);
setAllItems([]);
});
}
diff --git a/src/pages/Route/RouteListPage/index.tsx b/src/pages/Route/RouteListPage/index.tsx
index b94a868..1d7c299 100644
--- a/src/pages/Route/RouteListPage/index.tsx
+++ b/src/pages/Route/RouteListPage/index.tsx
@@ -22,6 +22,12 @@ export const RouteListPage = observer(() => {
pageSize: 50,
});
const { language } = languageStore;
+ const canWriteRoutes = authStore.canWrite("routes");
+ const canShowRoutePreview =
+ authStore.canWrite("stations") &&
+ authStore.canWrite("sights") &&
+ authStore.canWrite("routes");
+ const canShowActionsColumn = canWriteRoutes || canShowRoutePreview;
useEffect(() => {
const fetchData = async () => {
@@ -104,7 +110,7 @@ export const RouteListPage = observer(() => {
);
},
},
- {
+ ...(canShowActionsColumn ? [{
field: "actions",
headerName: "Действия",
width: 250,
@@ -112,14 +118,9 @@ export const RouteListPage = observer(() => {
headerAlign: "center" as const,
sortable: false,
renderCell: (params: GridRenderCellParams) => {
- const canWrite = authStore.canWrite("routes");
- const canShowRoutePreview =
- authStore.canRead("stations") &&
- authStore.canRead("sights") &&
- authStore.canRead("routes");
return (
- {canWrite && (
+ {canWriteRoutes && (
@@ -129,7 +130,7 @@ export const RouteListPage = observer(() => {
)}
- {canWrite && (
+ {canWriteRoutes && (
);
},
- },
+ }] : []),
];
const rows = routes.data.map((route) => ({
@@ -160,10 +161,12 @@ export const RouteListPage = observer(() => {
Маршруты
-
+ {canWriteRoutes && (
+
+ )}
- {ids.length > 0 && (
+ {canWriteRoutes && ids.length > 0 && (
-
-
-
+ {canWriteStations && ids.length > 0 && (
+
+
+
+ )}
{
- if (Array.isArray(newSelection)) {
- const selectedIds = newSelection
- .map((id: string | number) => {
- const numId =
- typeof id === "string"
- ? Number.parseInt(id, 10)
- : Number(id);
- return numId;
- })
- .filter(
- (id: number) =>
- !Number.isNaN(id) && id !== null && id !== undefined
- );
- setIds(selectedIds);
- } else if (
- newSelection &&
- typeof newSelection === "object" &&
- "ids" in newSelection
- ) {
- const idsSet = newSelection.ids as Set;
- const selectedIds = Array.from(idsSet)
- .map((id: string | number) => {
- const numId =
- typeof id === "string"
- ? Number.parseInt(id, 10)
- : Number(id);
- return numId;
- })
- .filter(
- (id: number) =>
- !Number.isNaN(id) && id !== null && id !== undefined
- );
- setIds(selectedIds);
- } else {
- setIds([]);
- }
- }}
+ onRowSelectionModelChange={
+ canWriteStations
+ ? (newSelection: any) => {
+ if (Array.isArray(newSelection)) {
+ const selectedIds = newSelection
+ .map((id: string | number) => {
+ const numId =
+ typeof id === "string"
+ ? Number.parseInt(id, 10)
+ : Number(id);
+ return numId;
+ })
+ .filter(
+ (id: number) =>
+ !Number.isNaN(id) && id !== null && id !== undefined
+ );
+ setIds(selectedIds);
+ } else if (
+ newSelection &&
+ typeof newSelection === "object" &&
+ "ids" in newSelection
+ ) {
+ const idsSet = newSelection.ids as Set;
+ const selectedIds = Array.from(idsSet)
+ .map((id: string | number) => {
+ const numId =
+ typeof id === "string"
+ ? Number.parseInt(id, 10)
+ : Number(id);
+ return numId;
+ })
+ .filter(
+ (id: number) =>
+ !Number.isNaN(id) && id !== null && id !== undefined
+ );
+ setIds(selectedIds);
+ } else {
+ setIds([]);
+ }
+ }
+ : undefined
+ }
localeText={ruRU.components.MuiDataGrid.defaultProps.localeText}
slots={{
noRowsOverlay: () => (
diff --git a/src/pages/User/UserListPage/index.tsx b/src/pages/User/UserListPage/index.tsx
index 76335b6..9969ddf 100644
--- a/src/pages/User/UserListPage/index.tsx
+++ b/src/pages/User/UserListPage/index.tsx
@@ -124,7 +124,7 @@ export const UserListPage = observer(() => {
)}
- {ids.length > 0 && (
+ {canWriteUsers && ids.length > 0 && (
- {ids.length > 0 && (
+ {canWriteVehicles && ids.length > 0 && (
)}
- {selectedIds.length > 0 && (
+ {canWriteDevices && selectedIds.length > 0 && (