import { baseApi } from '@ema-platform/api';
import type { Location, LocationType, ListResponse } from '../types/location';

const locationApi = baseApi.injectEndpoints({
  endpoints: (builder) => ({
    getLocationTypes: builder.query<ListResponse<LocationType>, void>({
      query: () => '/location-types',
    }),
    getLocations: builder.query<
      ListResponse<Location>,
      { take?: number }
    >({
      query: (params) => ({ url: '/locations', params }),
    }),
  }),
  overrideExisting: false,
});

export const { useGetLocationTypesQuery, useGetLocationsQuery } = locationApi;
