MSP-3204 add paths in apiPaths and create modulesServiceApi
This commit is contained in:
1 parent
e6ce9ba7d5
commit
1f39286a40
2 files changed
+34
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { createApi } from '@reduxjs/toolkit/query/react'
|
||||
|
||||
import { apiPaths } from '@constants/api/apiPaths.ts'
|
||||
|
||||
import { ModuleType } from '@pages/ModulesPage/module.type.ts'
|
||||
|
||||
import { axiosBaseQuery } from '@utils/apiUtils.ts'
|
||||
|
||||
const modulesServiceApi = createApi({
|
||||
reducerPath: 'modulesServiceApi',
|
||||
refetchOnFocus: true,
|
||||
tagTypes: ['modules'],
|
||||
baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseConfigUrl }),
|
||||
endpoints: (builder) => ({
|
||||
getModules: builder.query<ModuleType[], string>({
|
||||
query: () => ({ url: apiPaths.getModules, data: { limit: 1000 } }),
|
||||
providesTags: () => ['modules']
|
||||
}),
|
||||
removeModule: builder.mutation<void, string>({
|
||||
query: (id) => ({
|
||||
url: apiPaths.deleteModule,
|
||||
data: [id]
|
||||
}),
|
||||
invalidatesTags: ['modules']
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
export default modulesServiceApi
|
||||
Reference in new issue
Block a user