diff options
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/socket.js | 7 | ||||
| -rw-r--r-- | src/lib/utils.js | 7 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js index 6678b979..8d84073c 100644 --- a/src/lib/socket.js +++ b/src/lib/socket.js @@ -36,11 +36,8 @@ export const messages = (data) => ({ async payment() { let { amount, invoice } = data; - if (invoice) { - invoices.set({ ...get(invoices), [invoice.uuid]: invoice }); - } - - if (get(user).account_id !== data.account_id) return; + if (invoice) invalidate('app:invoice'); + if (get(user)?.account_id !== data.account_id) return; let payments = get(txns); let i = payments.findIndex((p) => p.id === data.id); diff --git a/src/lib/utils.js b/src/lib/utils.js index 7e0b8e4f..2bf6b800 100644 --- a/src/lib/utils.js +++ b/src/lib/utils.js @@ -37,7 +37,10 @@ export const get = (url, headers = {}) => export const post = (url, body, headers) => { headers = { ...headers, 'content-type': 'application/json', accept: 'application/json' }; return fetch(base + url, { method: 'POST', body: JSON.stringify(body), headers }) - .then((r) => r.text()) + .then(async (r) => { + if (r.ok) return r.text(); + throw new Error(await r.text()); + }) .then((body) => { try { body = JSON.parse(body); @@ -67,7 +70,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/]; export const success = (m) => { toast.pop(); |
