mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
fix: TS types
This commit is contained in:
@@ -12,9 +12,9 @@ import {
|
||||
useGetPresignedUrlAttachment,
|
||||
useUploadAttachments,
|
||||
} from '@/hooks/query/attachments';
|
||||
import { formatBytes } from '../Sales/Invoices/InvoiceForm/utils';
|
||||
import styles from './UploadAttachmentPopoverContent.module.scss';
|
||||
import { MIME_TYPES } from '@/components/Dropzone/mine-types';
|
||||
import { formatBytes } from '@/utils/format-bytes';
|
||||
|
||||
interface AttachmentFileCommon {
|
||||
originName: string;
|
||||
|
||||
@@ -415,15 +415,3 @@ export const useIsInvoiceTaxExclusive = () => {
|
||||
|
||||
return values.inclusive_exclusive_tax === TaxType.Exclusive;
|
||||
};
|
||||
|
||||
export function formatBytes(bytes, decimals = 2) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
|
||||
const k = 1024;
|
||||
const dm = decimals < 0 ? 0 : decimals;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
||||
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user