import React from 'react';
import {
  TableContainer,
  Table,
  TableHead,
  TableRow,
  TableBody,
  TableHeadCell,
  TableDataCell,
  TableCaption,
} from '@digigov/ui/content/Table';

const data = {
  title: 'Χρήστες',
  labels: {
    name: 'Ονοματεπώνυμο',
    role: 'Ρόλος',
    email: 'Email',
  },
  content: [
    {
      name: 'Μάριος Μενεξές',
      role: 'Χειριστής',
      email: 'marios@mail.com',
    },
    {
      name: 'Καλλιόπη Παπαδοπούλου',
      role: 'Χειριστής',
      email: 'kalliopi@mail.com',
    },
    {
      name: 'Μαρία Φλούπη',
      role: 'Διαχειριστής',
      email: 'maria@mail.com',
    },
  ],
};

export const DefinedWidth = (_: any) => {
  return (
    <TableContainer>
      <Table>
        {data && (
          <>
            <TableCaption>{data.title}</TableCaption>
            <TableHead>
              <TableRow>
                {data.labels && (
                  <>
                    <TableHeadCell width="50%">
                      {data.labels.name}
                    </TableHeadCell>
                    <TableHeadCell width="25%">
                      {data.labels.role}
                    </TableHeadCell>
                    <TableHeadCell width="25%">
                      {data.labels.email}
                    </TableHeadCell>
                  </>
                )}
              </TableRow>
            </TableHead>
            <TableBody>
              {data.content &&
                data.content.map((item, index) => (
                  <TableRow key={index}>
                    <TableHeadCell data-label={data.labels.name}>
                      {item.name}
                    </TableHeadCell>
                    <TableDataCell data-label={data.labels.role}>
                      {item.role}
                    </TableDataCell>
                    <TableDataCell data-label={data.labels.email}>
                      {item.email}
                    </TableDataCell>
                  </TableRow>
                ))}
            </TableBody>
          </>
        )}
      </Table>
    </TableContainer>
  );
};
export default DefinedWidth;
