From 4249e8004f6603c01f128d2938d6fd4e694b390c Mon Sep 17 00:00:00 2001 From: YasamanKahdooei Date: Wed, 17 Jul 2024 14:58:16 +0330 Subject: [PATCH] A bug fixed --- components/ComplainsDetails.tsx | 117 ++++++++++++++++------------- components/InspectorOperations.tsx | 6 +- lib/utils.ts | 33 ++------ 3 files changed, 76 insertions(+), 80 deletions(-) diff --git a/components/ComplainsDetails.tsx b/components/ComplainsDetails.tsx index bee0ac1..2cbd0a6 100644 --- a/components/ComplainsDetails.tsx +++ b/components/ComplainsDetails.tsx @@ -356,59 +356,71 @@ export default function ComplainsDetails({ > {data.contents?.map((item: any, index: any, array: any) => { return ( -
-
-
- + <> +
+
+ {array.length - index} -

- - {item.operationWithDescription.description}{" "} - توسط {item.sender == 0 ? "شهروند" : "بازرس"} - -

+
+
+
+ {/* + {array.length - index} + */} +

+ + { + item.operationWithDescription + .description + }{" "} + توسط{" "} + {item.sender == 0 ? "شهروند" : "بازرس"} + +

+
-

- - {convertFullTime(item.dateTime)} - -

-
-
- - {item.text ? item.text : "-"} - -
- {/* {item.media.length !== 0 && ( +

+ + {convertFullTime(item.dateTime)} + +

+
+
+ + {item.text ? item.text : "-"} + +
+ {/* {item.media.length !== 0 && ( )} */} -
-
- {item?.media.map((item: any, index: number) => { - return ( -
- openFileInNewTab( - item.data, - item.mimeType, - item.title - ) - } - > - - -

- {item.title} -

-
- {/* +
+ {item?.media.map( + (item: any, index: number) => { + return ( +
+ openFileInNewTab( + item.data, + item.mimeType, + item.title + ) + } + > + + +

+ {item.title} +

+
+ {/* downloadFile( @@ -418,12 +430,15 @@ export default function ComplainsDetails({ ) } /> */} -
- ); - })} +
+ ); + } + )} +
+
-
+ ); })}
diff --git a/components/InspectorOperations.tsx b/components/InspectorOperations.tsx index 8fb97b2..80e3814 100644 --- a/components/InspectorOperations.tsx +++ b/components/InspectorOperations.tsx @@ -166,10 +166,10 @@ export default function InspectorOperations({ const withDot = split?.map((item: string) => "." + item); const newAllowedExtensions = withDot?.join(","); const formatSize = (size: number) => { - const string = formatBytes(size); + const string = formatBytes(size); return ( - - {string} + + {string[0]} {string[1]} ); }; diff --git a/lib/utils.ts b/lib/utils.ts index de9bbe7..e50ead3 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -47,37 +47,18 @@ export function isAuthorized() { export function bytesToMB(bytes: number) { return Math.floor(bytes / (1024 * 1024)); } - export function formatBytes(bytes: number, decimals = 2) { - console.log(bytes); if (!+bytes) return "0 Bytes"; const k = 1024; const dm = decimals < 0 ? 0 : decimals; - const sizes = [ - "بایت", - "کیلوبایت", - "مگابایت", - "گیگابایت", - "TiB", - "PiB", - "EiB", - "ZiB", - "YiB", - ]; - // const sizes = [ - // "Bytes", - // "KB", - // "MB", - // "GiB", - // "TiB", - // "PiB", - // "EiB", - // "ZiB", - // "YiB", - // ]; + const sizes = ["بایت", "کیلوبایت", "مگابایت", "گیگابایت", "ترابایت", "PiB", "EiB", "ZiB", "YiB"]; const i = Math.floor(Math.log(bytes) / Math.log(k)); + const psFloaat = parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + const sz = sizes[i] - return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; -} + // return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`; + return [psFloaat , sz] + +} \ No newline at end of file