chore: initial import for test contour
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { API } from './apiSlice'
|
||||
|
||||
const authHeader = () => {
|
||||
const token = localStorage.getItem('token')
|
||||
return token ? { Authorization: `Bearer ${token}` } : {}
|
||||
}
|
||||
|
||||
export const locationApi = API.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
createLocation: build.mutation({
|
||||
query: ({ specialistId, data }) => ({
|
||||
url: `/specialist/${specialistId}/location/create`,
|
||||
method: 'POST',
|
||||
headers: authHeader(),
|
||||
body: JSON.stringify(data),
|
||||
}),
|
||||
invalidatesTags: ['Specialist'],
|
||||
}),
|
||||
updateLocation: build.mutation({
|
||||
query: ({ specialistId, locationId, data }) => {
|
||||
return ({
|
||||
url: `/specialist/${specialistId}/location/${locationId}`,
|
||||
method: 'PUT',
|
||||
headers: authHeader(),
|
||||
body: JSON.stringify(data),
|
||||
})},
|
||||
}),
|
||||
deleteLocation: build.mutation({
|
||||
query: (locationId) => ({
|
||||
url: `/location/${locationId}`,
|
||||
method: 'DELETE',
|
||||
headers: authHeader(),
|
||||
}),
|
||||
}),
|
||||
getEmptyLocations: build.query({
|
||||
query: () => {
|
||||
return {
|
||||
url: `/locations/empty`,
|
||||
headers: authHeader(),
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
export const {
|
||||
useCreateLocationMutation,
|
||||
useUpdateLocationMutation,
|
||||
useDeleteLocationMutation,
|
||||
useGetEmptyLocationsQuery,
|
||||
} = locationApi
|
||||
Reference in New Issue
Block a user