From 0eddd112ae260d585603f2559a96ae4773e3f94d Mon Sep 17 00:00:00 2001 From: maxim Date: Sun, 16 Mar 2025 21:18:38 +0300 Subject: [PATCH] update `list` for project routes --- src/components/CustomDataGrid.tsx | 2 +- src/pages/carrier/list.tsx | 12 ++++++++++-- src/pages/city/list.tsx | 12 ++++++++++-- src/pages/country/list.tsx | 4 ++-- src/pages/media/list.tsx | 31 ++++++++++++++++++------------- src/pages/route/list.tsx | 9 +++++++++ src/pages/sight/list.tsx | 14 +++++++++++--- src/pages/vehicle/list.tsx | 31 +++++++++++++++++++++---------- 8 files changed, 82 insertions(+), 33 deletions(-) diff --git a/src/components/CustomDataGrid.tsx b/src/components/CustomDataGrid.tsx index d2f2977..00ded27 100644 --- a/src/components/CustomDataGrid.tsx +++ b/src/components/CustomDataGrid.tsx @@ -7,7 +7,7 @@ interface CustomDataGridProps extends DataGridProps { hasCoordinates?: boolean } -const DEV_FIELDS = ['id', 'city_id', 'carrier_id'] as const +const DEV_FIELDS = ['id', 'code', 'country_code', 'city_id', 'carrier_id'] as const export const CustomDataGrid = ({hasCoordinates = false, columns = [], ...props}: CustomDataGridProps) => { const isDev = import.meta.env.DEV diff --git a/src/pages/carrier/list.tsx b/src/pages/carrier/list.tsx index 83f7478..c63dc3f 100644 --- a/src/pages/carrier/list.tsx +++ b/src/pages/carrier/list.tsx @@ -26,6 +26,14 @@ export const CarrierList = () => { align: 'left', headerAlign: 'left', }, + { + field: 'city', + headerName: 'Город', + type: 'string', + minWidth: 150, + align: 'left', + headerAlign: 'left', + }, { field: 'full_name', headerName: 'Полное имя', @@ -42,11 +50,11 @@ export const CarrierList = () => { { field: 'actions', headerName: 'Действия', + minWidth: 120, + display: 'flex', align: 'right', headerAlign: 'center', - minWidth: 120, sortable: false, - display: 'flex', renderCell: function render({row}) { return ( <> diff --git a/src/pages/city/list.tsx b/src/pages/city/list.tsx index d78746f..79698c1 100644 --- a/src/pages/city/list.tsx +++ b/src/pages/city/list.tsx @@ -26,6 +26,14 @@ export const CityList = () => { align: 'left', headerAlign: 'left', }, + { + field: 'country', + headerName: 'Cтрана', + type: 'string', + minWidth: 150, + align: 'left', + headerAlign: 'left', + }, { field: 'name', headerName: 'Название', @@ -36,11 +44,11 @@ export const CityList = () => { { field: 'actions', headerName: 'Действия', + minWidth: 120, + display: 'flex', align: 'right', headerAlign: 'center', - minWidth: 120, sortable: false, - display: 'flex', renderCell: function render({row}) { return ( <> diff --git a/src/pages/country/list.tsx b/src/pages/country/list.tsx index fec32ec..bc3accc 100644 --- a/src/pages/country/list.tsx +++ b/src/pages/country/list.tsx @@ -29,11 +29,11 @@ export const CountryList = () => { { field: 'actions', headerName: 'Действия', + minWidth: 120, + display: 'flex', align: 'right', headerAlign: 'center', - minWidth: 120, sortable: false, - display: 'flex', renderCell: function render({row}) { return ( <> diff --git a/src/pages/media/list.tsx b/src/pages/media/list.tsx index ad6d94e..83dca5b 100644 --- a/src/pages/media/list.tsx +++ b/src/pages/media/list.tsx @@ -2,6 +2,7 @@ import {type GridColDef} from '@mui/x-data-grid' import {CustomDataGrid} from '../../components/CustomDataGrid' import {DeleteButton, EditButton, List, ShowButton, useDataGrid} from '@refinedev/mui' import React from 'react' +import {MEDIA_TYPES} from '../../lib/constants' import {localeText} from '../../locales/ru/localeText' @@ -10,6 +11,15 @@ export const MediaList = () => { const columns = React.useMemo( () => [ + { + field: 'id', + headerName: 'ID', + type: 'number', + minWidth: 350, + display: 'flex', + align: 'left', + headerAlign: 'left', + }, { field: 'filename', headerName: 'Название', @@ -22,28 +32,23 @@ export const MediaList = () => { { field: 'media_type', headerName: 'Тип', - type: 'number', - minWidth: 150, - display: 'flex', - align: 'left', - headerAlign: 'left', - }, - { - field: 'id', - headerName: 'ID', - type: 'number', + type: 'string', display: 'flex', align: 'left', headerAlign: 'left', flex: 1, + renderCell: (params) => { + const value = params.row.media_type + return MEDIA_TYPES.find((type) => type.value === value)?.label || value + }, }, { field: 'actions', headerName: 'Действия', - align: 'right', - headerAlign: 'right', + minWidth: 120, display: 'flex', - flex: 1, + align: 'right', + headerAlign: 'center', sortable: false, renderCell: function render({row}) { return ( diff --git a/src/pages/route/list.tsx b/src/pages/route/list.tsx index 1f7eeab..d68e00c 100644 --- a/src/pages/route/list.tsx +++ b/src/pages/route/list.tsx @@ -31,6 +31,15 @@ export const RouteList = () => { align: 'left', headerAlign: 'left', }, + { + field: 'carrier', + headerName: 'Перевозчик', + type: 'string', + minWidth: 150, + display: 'flex', + align: 'left', + headerAlign: 'left', + }, { field: 'route_number', headerName: 'Номер маршрута', diff --git a/src/pages/sight/list.tsx b/src/pages/sight/list.tsx index 6de2b11..0350d0c 100644 --- a/src/pages/sight/list.tsx +++ b/src/pages/sight/list.tsx @@ -54,15 +54,23 @@ export const SightList = () => { display: 'flex', align: 'left', headerAlign: 'left', + }, + { + field: 'city', + headerName: 'Город', + type: 'string', + minWidth: 150, + align: 'left', + headerAlign: 'left', flex: 1, }, { field: 'actions', headerName: 'Действия', - align: 'right', - headerAlign: 'right', + minWidth: 120, display: 'flex', - flex: 1, + align: 'right', + headerAlign: 'center', sortable: false, renderCell: function render({row}) { return ( diff --git a/src/pages/vehicle/list.tsx b/src/pages/vehicle/list.tsx index dc50d6f..09804f1 100644 --- a/src/pages/vehicle/list.tsx +++ b/src/pages/vehicle/list.tsx @@ -2,6 +2,7 @@ import {type GridColDef} from '@mui/x-data-grid' import {CustomDataGrid} from '../../components/CustomDataGrid' import {DeleteButton, EditButton, List, ShowButton, useDataGrid} from '@refinedev/mui' import React from 'react' +import {VEHICLE_TYPES} from '../../lib/constants' import {localeText} from '../../locales/ru/localeText' @@ -31,18 +32,29 @@ export const VehicleList = () => { { field: 'type', headerName: 'Тип', - type: 'number', + type: 'string', + minWidth: 200, + display: 'flex', + align: 'left', + headerAlign: 'left', + renderCell: (params) => { + const value = params.row.type + return VEHICLE_TYPES.find((type) => type.value === value)?.label || value + }, + }, + { + field: 'city_id', + headerName: 'ID города', + type: 'string', minWidth: 150, display: 'flex', align: 'left', headerAlign: 'left', }, { - field: 'city_id', - headerName: 'ID города', - type: 'number', - minWidth: 70, - display: 'flex', + field: 'city', + headerName: 'Город', + type: 'string', align: 'left', headerAlign: 'left', flex: 1, @@ -50,12 +62,11 @@ export const VehicleList = () => { { field: 'actions', headerName: 'Действия', - align: 'right', - headerAlign: 'right', + minWidth: 120, display: 'flex', - flex: 1, + align: 'right', + headerAlign: 'center', sortable: false, - renderCell: function render({row}) { return ( <>