feat: Uploading company logo

This commit is contained in:
Ahmed Bouhuolia
2024-09-24 20:28:19 +02:00
parent d16c57b63b
commit 37fd4a1fdb
20 changed files with 404 additions and 171 deletions

View File

@@ -1,6 +1,16 @@
// @ts-nocheck
import { useMutation } from 'react-query';
import useApiRequest from '../useRequest';
import { transformToCamelCase } from '@/utils';
interface UploadAttachmentResponse {
createdAt: string;
id: number;
key: string;
mimeType: string;
originName: string;
size: number;
}
/**
* Uploads the given attachments.
@@ -8,8 +18,11 @@ import useApiRequest from '../useRequest';
export function useUploadAttachments(props) {
const apiRequest = useApiRequest();
return useMutation(
(values) => apiRequest.post('attachments', values),
return useMutation<UploadAttachmentResponse>(
(values) =>
apiRequest
.post('attachments', values)
.then((res) => transformToCamelCase(res.data?.data)),
props,
);
}