diff options
| author | Adam Soltys <[email protected]> | 2024-11-28 08:20:19 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-28 08:20:19 -0800 |
| commit | e294a1793e3e884ed3f6c095f4978ccd44255a16 (patch) | |
| tree | fa5b1c20c7d7007956bdd82b5d1f225dd9b61450 /src/lib/utils.ts | |
| parent | ba0e41bfaa79faf01bb586a4a0e27ca915855bb8 (diff) | |
| download | coinos-ui-e294a1793e3e884ed3f6c095f4978ccd44255a16.tar.gz coinos-ui-e294a1793e3e884ed3f6c095f4978ccd44255a16.zip | |
handle undefined
Diffstat (limited to 'src/lib/utils.ts')
| -rw-r--r-- | src/lib/utils.ts | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts index 641cec31..60e30fe5 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -274,7 +274,11 @@ const map = { IRR: "fa-IR", }; -export const loc = ({ currency: c, language: l }) => map[l]?.[c] || map[c]; +export const loc = (user) => { + if (!user) return; + const { currency: c, language: l } = user; + return map[l]?.[c] || map[c]; +}; export const f = (s: number, currency: string, locale = "en-US") => new Intl.NumberFormat(locale, { |
