mirror of
https://github.com/Tria-plc/emaui.git
synced 2026-08-26 19:12:50 +00:00
50 lines
1.4 KiB
TypeScript
50 lines
1.4 KiB
TypeScript
import { baseApi } from "@ema-platform/api";
|
|
import type {
|
|
Organization,
|
|
Profession,
|
|
ListResponse,
|
|
CreateProfessionPayload,
|
|
UpdateProfessionPayload,
|
|
} from "../types/configuration";
|
|
|
|
const configurationApi = baseApi.injectEndpoints({
|
|
endpoints: (builder) => ({
|
|
getOrganizations: builder.query<ListResponse<Organization>, void>({
|
|
query: () => "/organizations",
|
|
providesTags: ["Api"],
|
|
}),
|
|
|
|
getProfessions: builder.query<ListResponse<Profession>, string>({
|
|
query: (params) => ({
|
|
url: `/professions?q=${encodeURIComponent(params)}`,
|
|
}),
|
|
providesTags: ["Api", "backOfficeApi", "ProfessionApi"],
|
|
}),
|
|
createProfession: builder.mutation<Profession, CreateProfessionPayload>({
|
|
query: (body) => ({ url: "/professions", method: "POST", body }),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
updateProfession: builder.mutation<Profession, UpdateProfessionPayload>({
|
|
query: ({ id, ...body }) => ({
|
|
url: `/professions/${id}`,
|
|
method: "PUT",
|
|
body,
|
|
}),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
deleteProfession: builder.mutation<void, string>({
|
|
query: (id) => ({ url: `/professions/${id}`, method: "DELETE" }),
|
|
invalidatesTags: ["Api"],
|
|
}),
|
|
}),
|
|
overrideExisting: true,
|
|
});
|
|
|
|
export const {
|
|
useGetOrganizationsQuery,
|
|
useGetProfessionsQuery,
|
|
useCreateProfessionMutation,
|
|
useUpdateProfessionMutation,
|
|
useDeleteProfessionMutation,
|
|
} = configurationApi;
|