mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { baseApi } from '@ema-platform/api';
|
|
import type {
|
|
Result,
|
|
ListResponse,
|
|
CreateResultPayload,
|
|
UpdateResultPayload,
|
|
} from '../types/result';
|
|
|
|
const resultApi = baseApi.injectEndpoints({
|
|
endpoints: (builder) => ({
|
|
getResults: builder.query<ListResponse<Result>, void>({
|
|
query: () => '/results',
|
|
providesTags: ['Api'],
|
|
}),
|
|
getResult: builder.query<Result, string>({
|
|
query: (id) => `/results/${id}?i=exam,profile`,
|
|
providesTags: ['Api'],
|
|
}),
|
|
createResult: builder.mutation<Result, CreateResultPayload>({
|
|
query: (body) => ({ url: '/results', method: 'POST', body }),
|
|
invalidatesTags: ['Api'],
|
|
}),
|
|
updateResult: builder.mutation<Result, UpdateResultPayload>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/results/${id}`,
|
|
method: 'PUT',
|
|
body,
|
|
}),
|
|
invalidatesTags: ['Api'],
|
|
}),
|
|
deleteResult: builder.mutation<void, string>({
|
|
query: (id) => ({ url: `/results/${id}`, method: 'DELETE' }),
|
|
invalidatesTags: ['Api'],
|
|
}),
|
|
}),
|
|
overrideExisting: false,
|
|
});
|
|
|
|
export const {
|
|
useGetResultsQuery,
|
|
useGetResultQuery,
|
|
useLazyGetResultQuery,
|
|
useCreateResultMutation,
|
|
useUpdateResultMutation,
|
|
useDeleteResultMutation,
|
|
} = resultApi;
|