// src/data/passport/passport.requests.ts
import { Passport } from '@/data/passport/passport.model';
import { CommonResponseType, PageAble } from '@/helpers/types';
import { request } from '@/services/request';

export const passport_requests = {
    /**
     * Passport'lar ro'yxatini olish.
     * @param params Filtrlar va sahifalash parametrlari.  `cargoId` majburiy.
     */
    async getAll(params: { cargoId: number; page?: number; sort?: string; direction?: string; passportNumber?: string }) {
        if (!params || !params.cargoId) {
            throw new Error("cargoId is required for passport_requests.getAll");
        }
        // CommonResponseType ichida data: Passport[] bo'ladi, PageAble kerak emas bu yerda, chunki server PageAble qaytarmayapti.
        return request.get<CommonResponseType<Passport[]>>('/passports', { params });
    },

    // Boshqa metodlar (agar kerak bo'lsa - izohda qoldirilgan)
};