package com.gnx.telemedicine.dto.admin;

import java.util.List;

/**
 * Generic paginated response wrapper.
 * 
 * @param <T> The type of items in the list
 */
public record PaginatedResponse<T>(
    List<T> content,
    int page,
    int size,
    long totalElements,
    int totalPages,
    boolean first,
    boolean last
) {
    public static <T> PaginatedResponse<T> of(
            List<T> content,
            int page,
            int size,
            long totalElements) {
        int totalPages = (int) Math.ceil((double) totalElements / size);
        return new PaginatedResponse<>(
                content,
                page,
                size,
                totalElements,
                totalPages,
                page == 0,
                page >= totalPages - 1
        );
    }
}

