36 lines
948 B
JavaScript
36 lines
948 B
JavaScript
import {createApi} from "@reduxjs/toolkit/query/react";
|
|
import {baseQueryWithAuth} from "./baseQuery.js";
|
|
|
|
|
|
export const backupsApi = createApi({
|
|
reducerPath: 'backupsApi',
|
|
baseQuery: baseQueryWithAuth,
|
|
tagTypes: ['Backup'],
|
|
endpoints: (builder) => ({
|
|
getBackups: builder.query({
|
|
query: () => `/backups/`,
|
|
providesTags: ['Backup'],
|
|
}),
|
|
createBackup: builder.mutation({
|
|
query: () => ({
|
|
url: '/backups/',
|
|
method: 'POST',
|
|
}),
|
|
invalidatesTags: ['Backup'],
|
|
}),
|
|
deleteBackup: builder.mutation({
|
|
query: (backupId) => ({
|
|
url: `/backups/${backupId}/`,
|
|
method: 'DELETE',
|
|
}),
|
|
invalidatesTags: ['Backup'],
|
|
}),
|
|
}),
|
|
});
|
|
|
|
export const {
|
|
useGetBackupsQuery,
|
|
useCreateBackupMutation,
|
|
useDeleteBackupMutation,
|
|
} = backupsApi;
|