import React from 'react';
import { NumberFormat } from '../../services/utils.service';

interface IPropsFileSize extends React.ComponentProps<any> {
    size: number | string;
}

const FileSize: React.FunctionComponent<IPropsFileSize> = ({ size }: IPropsFileSize) => {
    const value = Number(size);

    // Mb
    if (size >= 1048576) {
        return <>{`${(value / 1048576).toFixed(2)} MB`}</>;
    }

    return <>{`${(value / 1024).toFixed(0)} KB`}</>;
};

export default FileSize;
