diff --git a/src/components/AssetMetadata/index.tsx b/src/components/AssetMetadata/index.tsx index 140fdaf1..361eb050 100644 --- a/src/components/AssetMetadata/index.tsx +++ b/src/components/AssetMetadata/index.tsx @@ -26,7 +26,7 @@ const AssetMetadata: FC = (props: Props) => { Size - {filesize(asset?.size, {round: 0})} + {filesize(asset?.size, {base: 10, round: 0})} {/* MIME type */} diff --git a/src/components/TableRow/index.tsx b/src/components/TableRow/index.tsx index 107b10ee..1d7bd1d0 100644 --- a/src/components/TableRow/index.tsx +++ b/src/components/TableRow/index.tsx @@ -253,7 +253,7 @@ const TableRow = (props: Props) => { }} > - {filesize(asset.size, {round: 0})} + {filesize(asset.size, {base: 10, round: 0})} diff --git a/src/constants.ts b/src/constants.ts index 564fe66b..8773cbcd 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -58,12 +58,12 @@ export const FACETS: (SearchFacetProps | null)[] = [ { name: 'kb', title: 'KB', - fn: val => val * 1000 + fieldModifier: fieldName => `round(${fieldName} / 1000)` }, { name: 'mb', title: 'MB', - fn: val => val * 1000000 + fieldModifier: fieldName => `round(${fieldName} / 1000000)` } ] }, diff --git a/src/modules/assets/index.ts b/src/modules/assets/index.ts index e6d8dfe1..e647403a 100644 --- a/src/modules/assets/index.ts +++ b/src/modules/assets/index.ts @@ -798,10 +798,12 @@ const constructFilter = (searchFacets: SearchFacetProps[], searchQuery?: string) // Get current modifier const currentModifier = options?.modifiers.find(m => m.name === modifier) - // Apply modifier fn (if present) - const modifiedValue = currentModifier ? currentModifier?.fn(value) : value + // Apply field modifier fn (if present) + const fieldValue = currentModifier?.fieldModifier + ? currentModifier.fieldModifier(field) + : field - return `${field} ${COMPARISON_OPERATOR_MAPPING[operators.comparison].value} ${modifiedValue}` + return `${fieldValue} ${COMPARISON_OPERATOR_MAPPING[operators.comparison].value} ${value}` } if (facet.type === 'select') { diff --git a/src/types/index.ts b/src/types/index.ts index b25498fb..068b3127 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -88,8 +88,7 @@ export type Order = { } export type SearchFacetNumberModifier = { - // TODO: use correct type - fn: (val: any) => any + fieldModifier?: (fieldName: string) => string name: string title: string }