diff options
| author | John Barratt <[email protected]> | 2023-03-07 10:29:49 -0800 |
|---|---|---|
| committer | John Barratt <[email protected]> | 2023-03-07 10:29:49 -0800 |
| commit | 8ef9568cd1bd822495ce005d4e4cfaa6cb0d92ce (patch) | |
| tree | 4ea5530cc2b7e5d970dc8a84cacfecfe2cce46b7 /src/lib/utils.js | |
| parent | c97fb43abba375920fff361ec5fa4eb64a5a0d3f (diff) | |
| parent | 0f44e3283c25c9783a52cf20957661da49d2f90b (diff) | |
| download | coinos-ui-notifications.tar.gz coinos-ui-notifications.zip | |
Merge branch 'master' of https://github.com/coinos/coinos-ui into notificationsnotifications
Diffstat (limited to 'src/lib/utils.js')
| -rw-r--r-- | src/lib/utils.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/utils.js b/src/lib/utils.js index d510195b..6617f76e 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -147,6 +147,14 @@ export const login = async (user, cookies) => { export const auth = (cookies) => ({ authorization: `Bearer ${cookies.get('token')}` }); +export const fiat = (amount, rate) => (amount * rate) / sats; +export const fd = async (req) => { + let obj = Object.fromEntries(await req.formData()); + for (let k in obj) + (obj[k] === 'undefined' && (obj[k] = undefined)) || (obj[k] === 'false' && (obj[k] = false)); + return obj; +}; + export const f = (s, currency) => new Intl.NumberFormat('en-US', { style: 'currency', @@ -236,4 +244,12 @@ export const validateEmail = (email) => { const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return re.test(email); -};
\ No newline at end of file +}; + +export const types = { + bitcoin: 'bitcoin', + lightning: 'lightning', + internal: 'internal', + pot: 'pot', + classic: 'classic' +}; |
