aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-11-03 01:28:01 -0700
committerAdam Soltys <[email protected]>2022-11-03 01:28:01 -0700
commit2af4a989092ae63eb9ae38ac35982b6bba2e917c (patch)
treeaf6552ed8222e90c129ad9e1609896646c47082c /src/lib
parent5d3618a4397f88ed37cd25f39261c3a2bcc2aab7 (diff)
downloadcoinos-ui-2af4a989092ae63eb9ae38ac35982b6bba2e917c.tar.gz
coinos-ui-2af4a989092ae63eb9ae38ac35982b6bba2e917c.zip
show who payments are with
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/socket.js4
-rw-r--r--src/lib/utils.js30
2 files changed, 20 insertions, 14 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js
index 94c1802e..672d008c 100644
--- a/src/lib/socket.js
+++ b/src/lib/socket.js
@@ -15,9 +15,9 @@ export const send = (type, data) => {
};
export const messages = (data) => ({
- id() {
+ id() {
last.set(Date.now());
- },
+ },
rate() {
rate.set(data);
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();
};