diff --git a/src/services/tokensService.ts b/src/services/tokensService.ts new file mode 100644 index 0000000..a29fbd0 --- /dev/null +++ b/src/services/tokensService.ts @@ -0,0 +1,30 @@ +import { createApi } from '@reduxjs/toolkit/query/react' +import { apiPaths } from '@constants/api/apiPaths.ts' + +import { + ApplicationTokenType, + NewApplicationTokenType, +} from '@pages/ApplicationsPage/applications.type.ts' + +import { axiosBaseQuery } from '@utils/apiUtils.ts' + +const tokensApi = createApi({ + reducerPath: 'tokensApi', + refetchOnFocus: true, + tagTypes: ['Tokens'], + baseQuery: axiosBaseQuery({ baseUrl: apiPaths.baseSystemUrl }), + endpoints: (builder) => ({ + createToken: builder.mutation< + ApplicationTokenType, + NewApplicationTokenType + >({ + query: ( NewApplicationTokenType) => ({ + url: apiPaths.createToken, + data: NewApplicationTokenType + }), + invalidatesTags: ['Tokens'] + }), + }) +}) + +export default tokensApi \ No newline at end of file