Skip to content
Snippets Groups Projects
Commit fed6fa0b authored by Jose Manuel Serrano Amaut's avatar Jose Manuel Serrano Amaut
Browse files

[REF]: Hide size formatted if not set or false

parent 56fa5724
No related branches found
No related tags found
No related merge requests found
......@@ -147,9 +147,7 @@ const FileCard: React.FC<FileCardProps> = (props: FileCardProps) => {
videoUrl
);
//The size formatted and rounded in 2 decimals
const sizeFormatted: string = localSize
? fileSizeFormater(localSize)
: "0 KB";
const sizeFormatted: string | undefined = fileSizeFormater(localSize);
//alwaysActive
const [showInfo, setShowInfo] = React.useState<boolean>(false);
......
......@@ -8,6 +8,6 @@ export type FileMosaicInfoLayerProps = {
onCloseInfo?:Function;
localName: string;
sizeFormatted: string;
sizeFormatted?: string;
localType?: string;
}
\ No newline at end of file
......@@ -14,7 +14,8 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
props: FileMosaicMainLayerProps
) => {
const {
darkMode,deleteIcon,
darkMode,
deleteIcon,
downloadIcon,
imageIcon,
infoIcon,
......@@ -52,7 +53,9 @@ const FileMosaicMainLayer: React.FC<FileMosaicMainLayerProps> = (
uploadStatus={uploadStatus}
localization={localization}
/>
{isActive && <FileMosaicSize sizeFormatted={sizeFormatted} />}
{isActive && sizeFormatted && (
<FileMosaicSize sizeFormatted={sizeFormatted} />
)}
</div>
<div className="file-mosaic-footer-right">
{isActive && (
......
......@@ -10,7 +10,7 @@ export interface FileMosaicMainLayerProps {
uploadStatus?: UPLOADSTATUS;
localization?: Localization;
sizeFormatted: string;
sizeFormatted?: string;
imageIcon: boolean;
onSee: ((imageSource: string | undefined) => void) | undefined;
......
......@@ -69,7 +69,6 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
} = props;
//localizers
//ref for anchor download element
const downloadRef = React.useRef<HTMLAnchorElement>(null);
......@@ -116,10 +115,7 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
);
//The size formatted and rounded in 2 decimals
const sizeFormatted: string = localSize
? fileSizeFormater(localSize)
: "0 KB";
const sizeFormatted: string| undefined = fileSizeFormater(localSize);
//alwaysActive
const [showInfo, setShowInfo] = React.useState<boolean>(false);
......@@ -210,7 +206,6 @@ const FileMosaic: React.FC<FileMosaicProps> = (props: FileMosaicProps) => {
onAbort?.(id);
};
if (isReady)
return (
<div
......
......@@ -2,10 +2,10 @@
* Gives a XX.XX format in Bytes KB, MB, GB or TB
* @param fileSize file size to give format in Bytes
*/
export const fileSizeFormater = (fileSize?: number): string => {
export const fileSizeFormater = (fileSize?: number | false): string| undefined => {
let result = "";
if (!fileSize) {
return 0 + " Bytes";
return undefined;
}
if (fileSize < 1024) {
result = fileSize + " Bytes"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment