import * as React from "react";
import { GridColDef } from "@mui/x-data-grid";
import DataGrid from "@kitUI/datagrid";
import privilegesStore from "@stores/privileges";

const columns: GridColDef[] = [
    { field: 'name', headerName: 'Привелегия', width: 150 },
    { field: 'description', headerName: 'Описание', width: 550 },//инфо из гитлаба.
    { field: 'type', headerName: 'Тип', width: 150 },
    { field: 'price', headerName: 'Стоимость', width: 50 }
]
export default () =>  {
    const {privileges} = privilegesStore()
    let rows = []
    if (Object.keys(privileges).length !== 0) {
        for (let [id, value] of Object.entries(privileges)) {
            rows.push({id:id,name:value.name,description:value.description,type:value.type,price:value.price})
        }
    }


  return (
        <DataGrid
          checkboxSelection={true}
          rows={ rows }
          columns={columns}
        />
  );
}
