"use client";
import React from "react";
import {
  Table,
  TableBody,
  TableRow,
  TableCell,
} from "@/app/shadcn_components/ui/table";
import { DocumentSection } from "./DocumentSection";
import { FilesFromSurveyor } from "@/app/db/schema/files_from_surveyor";

type Props = {
  uprn: string;
  files: FilesFromSurveyor[];
};

export const GenericDocumentsTable: React.FC<Props> = ({ uprn, files }) => {
  return (
    <Table className="min-w-full table-fixed divide-y divide-gray-200 shadow overflow-hidden border-b border-gray-200 sm:rounded-lg">
      <TableBody className="bg-white divide-y divide-gray-200">
        {files.map((file, index) => {
          return (
            <React.Fragment key={index}>
              <DocumentSection
                reportType={null}
                uprn={uprn}
                files={[file]} // array of rows
              />
              <TableRow className="hover:bg-transparent">
                <TableCell colSpan={3} className="h-3 p-0" />
              </TableRow>
            </React.Fragment>
          );
        })}
      </TableBody>
    </Table>
  );
};
