chore: initial import for test contour
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
/* global FormData */
|
||||
|
||||
import { API } from './apiSlice';
|
||||
|
||||
const authHeader = () => {
|
||||
const token = localStorage.getItem('token');
|
||||
return token ? { Authorization: `Bearer ${token}` } : {};
|
||||
};
|
||||
|
||||
export const certificateApi = API.injectEndpoints({
|
||||
endpoints: (build) => ({
|
||||
getCertificate: build.query({
|
||||
query: ({id}) => {
|
||||
return {
|
||||
url: `/specialist-docs/${id}`,
|
||||
method: 'GET',
|
||||
// headers: authHeader(),
|
||||
};
|
||||
},
|
||||
}),
|
||||
createCertificate: build.mutation({
|
||||
query: ({specialistId, data}) => {
|
||||
return {
|
||||
url: `/specialist/${specialistId}/specialist-docs/create`,
|
||||
method: 'POST',
|
||||
headers: authHeader(),
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
},
|
||||
}),
|
||||
updateCertificate: build.mutation({
|
||||
query: ({specialistId, id, data}) => {
|
||||
return {
|
||||
url: `/specialist/${specialistId}/specialist-docs/${id}`,
|
||||
method: 'PUT',
|
||||
headers: authHeader(),
|
||||
body: JSON.stringify(data),
|
||||
};
|
||||
},
|
||||
}),
|
||||
uploadSertificatePicture: build.mutation({
|
||||
query: ({ id, file }) => {
|
||||
const formData = new FormData();
|
||||
formData.append('picture', file);
|
||||
return {
|
||||
url: `/specialist-docs/picture/${id}`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
...authHeader(),
|
||||
},
|
||||
body: formData,
|
||||
};
|
||||
},
|
||||
}),
|
||||
deleteCertificate: build.mutation({
|
||||
query: ({id}) => {
|
||||
return {
|
||||
url: `/specialist-docs/${id}`,
|
||||
method: 'DELETE',
|
||||
headers: authHeader(),
|
||||
};
|
||||
},
|
||||
}),
|
||||
}),
|
||||
});
|
||||
|
||||
export const {
|
||||
useGetCertificateQuery,
|
||||
useCreateCertificateMutation,
|
||||
useUpdateCertificateMutation,
|
||||
useUploadSertificatePictureMutation,
|
||||
useDeleteCertificateMutation,
|
||||
} = certificateApi;
|
||||
Reference in New Issue
Block a user