import { Skeleton } from "@/components/shadcn/skeleton/skeleton"; import { DEFAULT_SCAN_JOBS_TAB, SCAN_JOBS_TAB, type ScanJobsTab, } from "@/types"; const AccountCellSkeleton = () => (
); const ScanInfoCellSkeleton = () => (
); const ProgressCellSkeleton = () => (
); const ScheduleCellSkeleton = () => (
); const DateCellSkeleton = () => (
); const ResourcesCellSkeleton = () => ( ); const DurationCellSkeleton = () => ( ); const StatusCellSkeleton = () => ( ); const ActionsCellSkeleton = () => ( ); const HeaderLabel = ({ width, sortable = false, }: { width: string; sortable?: boolean; }) => (
{sortable && }
); interface ColumnDescriptor { headerWidth: string; sortable?: boolean; Cell: () => React.JSX.Element; } const ACCOUNT_COLUMN: ColumnDescriptor = { headerWidth: "w-14", Cell: AccountCellSkeleton, }; const SCAN_INFO_COLUMN: ColumnDescriptor = { headerWidth: "w-8", sortable: true, Cell: ScanInfoCellSkeleton, }; const PROGRESS_COLUMN: ColumnDescriptor = { headerWidth: "w-14", Cell: ProgressCellSkeleton, }; const SCHEDULE_COLUMN: ColumnDescriptor = { headerWidth: "w-14", sortable: true, Cell: ScheduleCellSkeleton, }; const LAUNCHED_COLUMN: ColumnDescriptor = { headerWidth: "w-14", Cell: DateCellSkeleton, }; const RESOURCES_COLUMN: ColumnDescriptor = { headerWidth: "w-16", Cell: ResourcesCellSkeleton, }; const DURATION_COLUMN: ColumnDescriptor = { headerWidth: "w-14", Cell: DurationCellSkeleton, }; const STATUS_COLUMN: ColumnDescriptor = { headerWidth: "w-10", Cell: StatusCellSkeleton, }; const COMPLETED_COLUMN: ColumnDescriptor = { headerWidth: "w-16", sortable: true, Cell: DateCellSkeleton, }; const NEXT_RUN_COLUMN: ColumnDescriptor = { headerWidth: "w-14", sortable: true, Cell: DateCellSkeleton, }; const COLUMNS_BY_TAB: Record = { [SCAN_JOBS_TAB.ACTIVE]: [ ACCOUNT_COLUMN, SCAN_INFO_COLUMN, PROGRESS_COLUMN, SCHEDULE_COLUMN, LAUNCHED_COLUMN, ], [SCAN_JOBS_TAB.COMPLETED]: [ ACCOUNT_COLUMN, SCAN_INFO_COLUMN, RESOURCES_COLUMN, DURATION_COLUMN, STATUS_COLUMN, SCHEDULE_COLUMN, COMPLETED_COLUMN, ], [SCAN_JOBS_TAB.SCHEDULED]: [ ACCOUNT_COLUMN, SCAN_INFO_COLUMN, SCHEDULE_COLUMN, NEXT_RUN_COLUMN, ], }; interface SkeletonTableScansProps { tab?: ScanJobsTab; rows?: number; } export const SkeletonTableScans = ({ tab = DEFAULT_SCAN_JOBS_TAB, rows = 6, }: SkeletonTableScansProps = {}) => { const columns = COLUMNS_BY_TAB[tab]; return (
{/* Toolbar — mirrors DataTable's flex-col → md:flex-row layout (no search, only total entries) */}
{/* Table */} {columns.map((column, i) => ( ))} {/* Actions - empty header */} {Array.from({ length: rows }).map((_, rowIdx) => ( {columns.map(({ Cell }, colIdx) => ( ))} ))}
{/* Pagination — mirrors DataTablePagination's "justify-end gap-6 py-1.5" */}
{/* Rows per page group */}
{/* Page info + 4 chevron nav buttons */}
); };