'use client' import type { ReactNode } from 'react' import type { PaginationListColumnType } from '@/types' import type { PaginatedListRow } from '@/components/paginated-list/paginatedListUtils' import AdminState from '@/components/feedback/AdminState' import { Skeleton } from '@/components/feedback/LoadingState' interface Props { columns: PaginationListColumnType[] data: PaginatedListRow[] isLoading: boolean onRenderCell: (item: PaginatedListRow, columnKey: React.Key) => ReactNode } const MobileCardSkeleton = () => (
) export default function PaginatedListCards({ columns, data, isLoading, onRenderCell }: Props) { if (isLoading && data.length === 0) { return (
{Array.from({ length: 5 }).map((_, index) => ( ))}
) } if (data.length === 0) { return ( ) } const detailColumns = columns.filter((column) => column.field !== 'actions') const actionsColumn = columns.find((column) => column.field === 'actions') return (
{data.map((item, index) => (
{detailColumns.map((column) => (
{column.label}
{onRenderCell(item, column.field)}
))}
{actionsColumn ? (
{onRenderCell(item, actionsColumn.field)}
) : null}
))}
) }