import type { PaginationMeta } from '@/types/models';
import type { PaginatedResponse } from '@/types/responses';

export const buildPaginationMeta = (
  total: number,
  limit: number,
  offset: number
): PaginationMeta => {
  return {
    total,
    limit,
    offset,
    hasMore: offset + limit < total,
  };
};

export const buildPaginatedResponse = <T>(
  data: T[],
  total: number,
  limit: number,
  offset: number
): PaginatedResponse<T> => {
  return {
    success: true,
    data,
    pagination: buildPaginationMeta(total, limit, offset),
  };
};
