diff --git a/src/App.tsx b/src/App.tsx index d5f50e6..b0ce191 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -24,8 +24,9 @@ import {ArticleList, ArticleCreate, ArticleEdit} from './pages/article' import {SightList, SightCreate, SightEdit} from './pages/sight' import {StationList, StationCreate, StationEdit} from './pages/station' import {VehicleList, VehicleCreate, VehicleEdit} from './pages/vehicle' +import {RouteList, RouteCreate, RouteEdit} from './pages/route' -import {CountryIcon, CityIcon, CarrierIcon, MediaIcon, ArticleIcon, SightIcon, StationIcon, VehicleIcon} from './components/ui/Icons' +import {CountryIcon, CityIcon, CarrierIcon, MediaIcon, ArticleIcon, SightIcon, StationIcon, VehicleIcon, RouteIcon} from './components/ui/Icons' function App() { return ( @@ -135,6 +136,19 @@ function App() { icon: , }, }, + { + name: 'route', + list: '/route', + create: '/route/create', + edit: '/route/edit/:id', + // добавить SHOW для route->station (https://wn.krbl.ru/route/station) + // добавить SHOW для route->vehicle (https://wn.krbl.ru/route/vehicle) + meta: { + canDelete: true, + label: 'Маршруты', + icon: , + }, + }, ]} options={{ syncWithLocation: true, @@ -204,6 +218,12 @@ function App() { } /> + + } /> + } /> + } /> + + } /> { + const { + saveButtonProps, + refineCore: {formLoading}, + register, + control, + formState: {errors}, + } = useForm({ + refineCoreProps: { + resource: 'route/', + }, + }) + + return ( + + + + String(value), + })} + error={!!(errors as any)?.route_number} + helperText={(errors as any)?.route_number?.message} + margin="normal" + fullWidth + InputLabelProps={{shrink: true}} + type="text" + label={'Route Number'} + name="route_number" + /> + field.onChange(e.target.checked)} />} label="Route Direction" />} + /> + + + ) +} diff --git a/src/pages/route/edit.tsx b/src/pages/route/edit.tsx new file mode 100644 index 0000000..c5f1a1c --- /dev/null +++ b/src/pages/route/edit.tsx @@ -0,0 +1,54 @@ +import {Box, TextField, FormControlLabel, Checkbox} from '@mui/material' +import {Edit} from '@refinedev/mui' +import {useForm} from '@refinedev/react-hook-form' +import {Controller} from 'react-hook-form' + +export const RouteEdit = () => { + const { + saveButtonProps, + register, + control, + formState: {errors}, + } = useForm({}) + + return ( + + + + String(value), + })} + error={!!(errors as any)?.route_number} + helperText={(errors as any)?.route_number?.message} + margin="normal" + fullWidth + InputLabelProps={{shrink: true}} + type="text" + label={'Route Number'} + name="route_number" + /> + field.onChange(e.target.checked)} />} label="Route Direction" />} + /> + + + ) +} diff --git a/src/pages/route/index.ts b/src/pages/route/index.ts new file mode 100644 index 0000000..fbafdcf --- /dev/null +++ b/src/pages/route/index.ts @@ -0,0 +1,3 @@ +export * from './create' +export * from './edit' +export * from './list' diff --git a/src/pages/route/list.tsx b/src/pages/route/list.tsx new file mode 100644 index 0000000..c55e3cd --- /dev/null +++ b/src/pages/route/list.tsx @@ -0,0 +1,74 @@ +import {DataGrid, type GridColDef} from '@mui/x-data-grid' +import {DeleteButton, EditButton, List, useDataGrid} from '@refinedev/mui' +import React from 'react' + +export const RouteList = () => { + const {dataGridProps} = useDataGrid({ + resource: 'route/', + }) + + const columns = React.useMemo( + () => [ + { + field: 'id', + headerName: 'ID', + type: 'number', + minWidth: 70, + display: 'flex', + align: 'left', + headerAlign: 'left', + }, + { + field: 'carrier_id', + headerName: 'Carrier ID', + type: 'number', + minWidth: 70, + display: 'flex', + align: 'left', + headerAlign: 'left', + }, + { + field: 'route_number', + headerName: 'Route Number', + type: 'string', + minWidth: 150, + display: 'flex', + align: 'left', + headerAlign: 'left', + }, + { + field: 'route_direction', + headerName: 'Route Direction', + type: 'boolean', + display: 'flex', + align: 'left', + headerAlign: 'left', + flex: 1, + }, + { + field: 'actions', + headerName: 'Actions', + align: 'right', + headerAlign: 'center', + minWidth: 100, + sortable: false, + display: 'flex', + renderCell: function render({row}) { + return ( + <> + + + + ) + }, + }, + ], + [], + ) + + return ( + + row.id} /> + + ) +}