import { apiClient } from '@/lib/api-client';
import { PassengerFilters } from '@/types';
import { Passenger, PaginatedResponse } from '@edr/types';

export const passengersApi = {
  getAll: (filters?: PassengerFilters) => {
    const params = new URLSearchParams();
    if (filters?.search) params.append('search', filters.search);
    if (filters?.verified !== undefined) params.append('verified', filters.verified.toString());
    if (filters?.role) params.append('role', filters.role);
    if (filters?.page) params.append('page', filters.page.toString());
    if (filters?.pageSize) params.append('pageSize', filters.pageSize.toString());
    
    return apiClient.get<PaginatedResponse<Passenger.IPassenger>>(`/passengers?${params.toString()}`);
  },

  getById: (id: string) => {
    return apiClient.get<Passenger.IPassenger>(`/passengers/${id}`);
  },

  update: (id: string, data: Partial<Passenger.IPassenger>) => {
    return apiClient.patch<Passenger.IPassenger>(`/passengers/${id}`, data);
  },
};
