import type { DataTablePagination } from '@/types/data-table';

export function groupedTableRowNumber(firstItem: number | undefined, index: number): number {
    return (firstItem ?? 1) + index;
}

export function buildPaginationSummary(
    pagination: DataTablePagination | undefined,
    showingCount: number,
    itemLabel: string,
): string | null {
    if (!pagination) {
        return null;
    }

    const { total } = pagination;

    if (total === 0) {
        return `Menampilkan 0 ${itemLabel}`;
    }

    return `Menampilkan ${showingCount} ${itemLabel} dari ${total}`;
}
