All checks were successful
release-tag / release-image (push) Successful in 2m17s
Co-authored-by: itoshi <kkzemeow@gmail.com> Co-authored-by: Spynder <19329095+Spynder@users.noreply.github.com> Reviewed-on: #12 Co-authored-by: Alexander Lazarenko <kerblif@unprism.ru> Co-committed-by: Alexander Lazarenko <kerblif@unprism.ru>
170 lines
3.8 KiB
TypeScript
170 lines
3.8 KiB
TypeScript
import React from "react";
|
|
import { type GridColDef } from "@mui/x-data-grid";
|
|
import {
|
|
DeleteButton,
|
|
EditButton,
|
|
List,
|
|
ShowButton,
|
|
useDataGrid,
|
|
} from "@refinedev/mui";
|
|
import { Stack } from "@mui/material";
|
|
import { CustomDataGrid } from "@components";
|
|
import { localeText } from "../../locales/ru/localeText";
|
|
import { cityStore, languageStore } from "@stores";
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
export const SightList = observer(() => {
|
|
const { city_id } = cityStore;
|
|
const { language } = languageStore;
|
|
|
|
const { dataGridProps } = useDataGrid({
|
|
resource: "sight",
|
|
|
|
meta: {
|
|
headers: {
|
|
"Accept-Language": language,
|
|
},
|
|
},
|
|
|
|
filters: {
|
|
permanent: [
|
|
{
|
|
field: "cityID",
|
|
operator: "eq",
|
|
value: city_id === "0" ? null : city_id,
|
|
},
|
|
],
|
|
},
|
|
});
|
|
|
|
const columns = React.useMemo<GridColDef[]>(
|
|
() => [
|
|
{
|
|
field: "id",
|
|
headerName: "ID",
|
|
type: "number",
|
|
minWidth: 70,
|
|
display: "flex",
|
|
align: "left",
|
|
headerAlign: "left",
|
|
},
|
|
{
|
|
field: "name",
|
|
headerName: "Название",
|
|
type: "string",
|
|
minWidth: 150,
|
|
display: "flex",
|
|
align: "left",
|
|
headerAlign: "left",
|
|
flex: 1,
|
|
},
|
|
{
|
|
field: "latitude",
|
|
headerName: "Широта",
|
|
type: "number",
|
|
minWidth: 150,
|
|
display: "flex",
|
|
align: "left",
|
|
headerAlign: "left",
|
|
},
|
|
{
|
|
field: "longitude",
|
|
headerName: "Долгота",
|
|
type: "number",
|
|
minWidth: 150,
|
|
display: "flex",
|
|
align: "left",
|
|
headerAlign: "left",
|
|
},
|
|
{
|
|
field: "city_id",
|
|
headerName: "ID города",
|
|
type: "number",
|
|
minWidth: 70,
|
|
display: "flex",
|
|
align: "left",
|
|
headerAlign: "left",
|
|
},
|
|
{
|
|
field: "city",
|
|
headerName: "Город",
|
|
type: "string",
|
|
minWidth: 100,
|
|
align: "left",
|
|
headerAlign: "left",
|
|
flex: 1,
|
|
},
|
|
{
|
|
field: "thumbnail",
|
|
headerName: "Карточка",
|
|
type: "string",
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
field: "watermark_lu",
|
|
headerName: "Вод. знак (lu)",
|
|
type: "string",
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
field: "watermark_rd",
|
|
headerName: "Вод. знак (rd)",
|
|
type: "string",
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
field: "left_article",
|
|
headerName: "Левая статья",
|
|
type: "number",
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
field: "preview_article",
|
|
headerName: "Пред. просмотр статьи",
|
|
type: "number",
|
|
minWidth: 150,
|
|
},
|
|
{
|
|
field: "actions",
|
|
headerName: "Действия",
|
|
minWidth: 120,
|
|
display: "flex",
|
|
align: "right",
|
|
headerAlign: "center",
|
|
sortable: false,
|
|
filterable: false,
|
|
disableColumnMenu: true,
|
|
renderCell: function render({ row }) {
|
|
return (
|
|
<>
|
|
<EditButton hideText recordItemId={row.id} />
|
|
<ShowButton hideText recordItemId={row.id} />
|
|
<DeleteButton
|
|
hideText
|
|
confirmTitle="Вы уверены?"
|
|
recordItemId={row.id}
|
|
/>
|
|
</>
|
|
);
|
|
},
|
|
},
|
|
],
|
|
[]
|
|
);
|
|
|
|
return (
|
|
<List>
|
|
<Stack gap={2.5}>
|
|
<CustomDataGrid
|
|
{...dataGridProps}
|
|
languageEnabled
|
|
columns={columns}
|
|
localeText={localeText}
|
|
getRowId={(row: any) => row.id}
|
|
hasCoordinates
|
|
/>
|
|
</Stack>
|
|
</List>
|
|
);
|
|
});
|