55 lines
1.9 KiB
TypeScript
55 lines
1.9 KiB
TypeScript
import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
import { baseQuery } from "../baseQuery";
|
|
|
|
export const attractionsApi = createApi({
|
|
reducerPath: 'attractionsApi',
|
|
// baseQuery: fetchBaseQuery({
|
|
// baseUrl: 'https://testingapi.citycards.betadelivery.com',
|
|
// }),
|
|
baseQuery,
|
|
endpoints: (builder) => ({
|
|
getAttractionFilters: builder.query({
|
|
// cityId is passed as the query param
|
|
query: (cityId) => `/attractions/customer/filters?cityXid=${cityId}`,
|
|
}),
|
|
|
|
getCustomerAttractions: builder.query({
|
|
// cityId is required, others optional
|
|
query: ({ cityId, categoryId, isBookingRequired, cardType, search }) => {
|
|
const params = new URLSearchParams();
|
|
|
|
// required
|
|
params.append('cityXid', cityId);
|
|
|
|
// optional
|
|
if (categoryId) params.append('categoryXid', categoryId);
|
|
if (isBookingRequired !== undefined) params.append('isBookingRequired', isBookingRequired);
|
|
if (cardType) params.append('cardType', cardType);
|
|
if (search) params.append('search', search);
|
|
|
|
return `/attractions/customer/customer-attractions?${params.toString()}`;
|
|
},
|
|
}),
|
|
getAttractionsForHomePage: builder.query({
|
|
// cityId is required, others optional
|
|
query: ({ cityId, categoryId}) => {
|
|
const params = new URLSearchParams();
|
|
|
|
// required
|
|
params.append('cityXid', cityId);
|
|
|
|
// optional
|
|
if (categoryId) params.append('categoryXid', categoryId);
|
|
|
|
return `/attractions/list/city-attractions?${params.toString()}`;
|
|
},
|
|
}),
|
|
|
|
getAttractionDetailsById: builder.query({
|
|
query: (id: number) => `/attractions/customer/${id}`,
|
|
}),
|
|
|
|
}),
|
|
});
|
|
|
|
export const { useGetAttractionFiltersQuery,useGetCustomerAttractionsQuery,useGetAttractionDetailsByIdQuery,useGetAttractionsForHomePageQuery } = attractionsApi; |