import React from 'react';
import DataStateSkeleton from '@/components/helper/skeleton/DataStateSkeleton';
import Table from '@/components/Table';
import { ProductionResult } from '@/types/api/report/production-result';
import { ColumnDef } from '@tanstack/react-table';

type ProductionResultColumn =
  | ColumnDef<ProductionResult>
  | {
      header: string;
      columns: Array<{
        header: string;
        accessorKey?: string;
        cell?: (props: {
          row: { original: ProductionResult };
        }) => React.ReactNode;
      }>;
    };

const ProductionResultSkeleton = ({
  columns,
  icon,
  title,
  subtitle,
}: {
  columns: ProductionResultColumn[];
  icon: React.ReactNode;
  title: string;
  subtitle: string;
}) => {
  return (
    <div className='relative size-full'>
      <Table
        data={[]}
        columns={columns}
        isLoading={true}
        className={{
          skeletonCellClassName: 'animate-none w-full h-5 bg-base-content/4',
          headerColumnClassName: 'whitespace-nowrap',
          containerClassName: 'mb-0 overflow-hidden',
          tableWrapperClassName: 'overflow-hidden',
        }}
      />
      <div className='absolute inset-0 flex items-center justify-center'>
        <DataStateSkeleton icon={icon} title={title} description={subtitle} />
      </div>
    </div>
  );
};

export default ProductionResultSkeleton;
