adminFront/src/pages/dashboard/Content/Tariffs/Privileges/Privileges.tsx

52 lines
1.6 KiB
TypeScript
Raw Normal View History

import { GridColDef } from "@mui/x-data-grid";
import DataGrid from "@kitUI/datagrid";
2023-05-23 12:21:54 +00:00
import { openPrivilegePriceModal, usePrivilegeStore } from "@stores/privileges";
import { IconButton } from "@mui/material";
import { MouseEventHandler } from "react";
import EditIcon from '@mui/icons-material/Edit';
2023-03-06 13:26:55 +00:00
const columns: GridColDef[] = [
2023-03-06 13:26:55 +00:00
{ field: 'id', headerName: 'id', width: 40 },
{ field: 'name', headerName: 'Привелегия', width: 150 },
{ field: 'description', headerName: 'Описание', width: 550 },//инфо из гитлаба.
{ field: 'type', headerName: 'Тип', width: 150 },
2023-05-23 12:21:54 +00:00
{ field: 'price', headerName: 'Стоимость', width: 50 },
{
field: "changeValue",
headerName: "Изменить",
sortable: false,
renderCell: (params) => {
const onClick: MouseEventHandler<HTMLButtonElement> = () => {
openPrivilegePriceModal(params.row.id, params.row.price);
};
return (
<IconButton onClick={onClick}>
<EditIcon />
</IconButton>
);
},
},
2023-03-06 13:26:55 +00:00
];
2023-05-23 12:21:54 +00:00
export default function Privileges() {
2023-03-06 13:26:55 +00:00
const privileges = usePrivilegeStore(state => state.privileges);
2023-03-06 13:26:55 +00:00
const privilegesGridData = privileges.map(privilege => ({
id: privilege.privilegeId,
name: privilege.name,
description: privilege.description,
type: privilege.type,
price: privilege.pricePerUnit,
}));
2023-03-06 13:26:55 +00:00
return (
<DataGrid
2023-03-06 13:26:55 +00:00
// checkboxSelection={true}
rows={privilegesGridData}
columns={columns}
/>
2023-03-06 13:26:55 +00:00
);
}