diff options
| author | Adam Soltys <[email protected]> | 2022-11-03 01:28:01 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-11-03 01:28:01 -0700 |
| commit | 2af4a989092ae63eb9ae38ac35982b6bba2e917c (patch) | |
| tree | af6552ed8222e90c129ad9e1609896646c47082c /src/lib/utils.js | |
| parent | 5d3618a4397f88ed37cd25f39261c3a2bcc2aab7 (diff) | |
| download | coinos-ui-2af4a989092ae63eb9ae38ac35982b6bba2e917c.tar.gz coinos-ui-2af4a989092ae63eb9ae38ac35982b6bba2e917c.zip | |
show who payments are with
Diffstat (limited to 'src/lib/utils.js')
| -rw-r--r-- | src/lib/utils.js | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index c33b1cf9..a2829ca4 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -64,13 +64,7 @@ export function reverseFormat(val, locale) { return Number.isNaN(reversedVal) ? 0 : +reversedVal; } -export let protectedRoutes = [ - /customers/, - /dashboard/, - /settings/, - /transactions/, - /support/ -]; +export let protectedRoutes = [/customers/, /dashboard/, /settings/, /transactions/, /support/]; export const success = (m) => { toast.pop(); @@ -138,16 +132,28 @@ export const f = (s, currency) => .replace('CA', ''); export const s = (s) => new Intl.NumberFormat('en-US', { maximumFractionDigits: 0 }).format(s); +export const sat = (s) => { + let p = Math.floor(Math.log(s) / Math.LN10 + 0.000000001); + let d = Math.floor((p + 1) / 3); + + return ( + '⚡️' + + (parseInt(s) > 0 + ? new Intl.NumberFormat('en-US', { maximumFractionDigits: 1 }).format(s / Math.pow(1000, d)) + + ['', 'K', 'M', 'G'][d] + : 0 + ).toString() + ); +}; export const sats = 100000000; export const back = () => browser && history.go(-1); export const focus = (el) => setTimeout(() => el.focus()); - export const wait = async (f, s = 300) => { - let i = 0; - while (!(await f()) && i < s) (await sleep(1000)) && i++; - if (i >= s) throw new Error("timeout"); - return f(); + let i = 0; + while (!(await f()) && i < s) (await sleep(1000)) && i++; + if (i >= s) throw new Error('timeout'); + return f(); }; |
