import { type FileAsset } from '@material-hu/types/attachments';

import api from 'src/config/api';
import { type SignatureFile } from 'src/pages/dashboard/serviceManagement/types';
import { FileTypes } from 'src/types/attachments';
import { bytesToSize } from 'src/utils/bytes';

export const uploadSignature = (file: SignatureFile) =>
  api.post<FileAsset>('/file-assets', {
    name: file.name,
    type: FileTypes.IMAGE,
    contentType: file.type,
    size: bytesToSize(file.size),
  });
