summaryrefslogtreecommitdiff
path: root/src/components/DataTable.tsx
blob: e75af180e2bf1203dceb27e581241ca604bf0159 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
import ListTable from './ListTable';
import Button from './Button';

interface Field {
  key: string;
  label: string;
}

interface Props {
  title: string;
  items: any[];
  fields: Field[];
  handleRowClick?: (index: number) => void;
}

const DataTable: React.FC<Props> = ({ title, items, fields, handleRowClick = () => {} }) => {
  return (
    <>
      <div className="mb-2 flex justify-between items-center">
        <span className="text-2xl font-bold">{title}</span>
        <Button size="sm">Добавить</Button>
      </div>
      <ListTable items={items} fields={fields} handleRowClick={handleRowClick} />
    </>
  );
};

export default DataTable;