import React, { useMemo } from 'react';
import { useOutletContext } from 'react-router-dom';
import {
  MaterialReactTable,
  useMaterialReactTable,
  type MRT_ColumnDef,
} from 'material-react-table';
import type { Guest } from '../slices/api/adminSlice';

function Dashboard() {
  const guests: Guest[] = useOutletContext();
  const columns = useMemo<MRT_ColumnDef<Guest>[]>(
    () => [
      {
        accessorKey: 'firstName',
        header: 'First Name',
        size: 150,
      },
      {
        accessorKey: 'lastName',
        header: 'Last Name',
        size: 150,
      },
      {
        accessorKey: 'attendance',
        header: 'Attendance',
        size: 50,
      },
      {
        accessorKey: 'email',
        header: 'Email',
        size: 150,
      },
      {
        accessorKey: 'message',
        header: 'Message',
        size: 200,
      },
      {
        accessorKey: 'partySize',
        header: 'Party Size',
        size: 50,
      },
      // {
      //   accessorKey: 'partyList',
      //   header: 'Party List',
      //   size: 150,
      // },
    ],
    []
  );
  const table = useMaterialReactTable({
    columns,
    data: guests,
  });

  return <MaterialReactTable table={table} />;
}

export default Dashboard;
