X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/fb48b7f876cf7c8b402ba05c16dffaade0a9f655..03c11b879ff72814f50b0d790b0aacea12c687d3:/src/common/formatters.ts?ds=sidebyside diff --git a/src/common/formatters.ts b/src/common/formatters.ts index 0402f390..60e6cd59 100644 --- a/src/common/formatters.ts +++ b/src/common/formatters.ts @@ -2,10 +2,15 @@ // // SPDX-License-Identifier: AGPL-3.0 -export const formatDate = (isoDate: string) => { - const date = new Date(isoDate); - const text = date.toLocaleString(); - return text === 'Invalid Date' ? "" : text; +import { PropertyValue } from "~/models/search-bar"; + +export const formatDate = (isoDate?: string | null) => { + if (isoDate) { + const date = new Date(isoDate); + const text = date.toLocaleString(); + return text === 'Invalid Date' ? "(none)" : text; + } + return "(none)"; }; export const formatFileSize = (size?: number) => { @@ -64,3 +69,12 @@ const FILE_SIZES = [ unit: "B" } ]; + +export const formatPropertyValue = (pv: PropertyValue) => { + if (pv.key) { + return pv.value + ? `${pv.key}: ${pv.value}` + : pv.key; + } + return ""; +};