aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/socket.js4
-rw-r--r--src/lib/store.js3
-rw-r--r--src/lib/upload.js2
-rw-r--r--src/lib/utils.js11
4 files changed, 16 insertions, 4 deletions
diff --git a/src/lib/socket.js b/src/lib/socket.js
index 7cce0071..fb77333f 100644
--- a/src/lib/socket.js
+++ b/src/lib/socket.js
@@ -1,5 +1,5 @@
import { get } from 'svelte/store';
-import { invoices, newPayment, rate } from '$lib/store';
+import { invoices, newPayment, rate, user } from '$lib/store';
import { success } from '$lib/utils';
import { env } from '$env/dynamic/public';
@@ -21,7 +21,7 @@ export const messages = (data) => ({
payment() {
let { amount, invoice } = data;
- if (get(user).account_id !== data.account_id ) return;
+ if (get(user).account_id !== data.account_id) return;
if (invoice) {
invoices.set({ ...get(invoices), [invoice.uuid]: invoice });
diff --git a/src/lib/store.js b/src/lib/store.js
index 765e14cf..ffafa70b 100644
--- a/src/lib/store.js
+++ b/src/lib/store.js
@@ -27,7 +27,8 @@ const persistLocal = (key, defaultValue) => {
return s;
};
-export const redirect = writable();
+export const invoiceRedirect = writable();
+export const loginRedirect = writable();
export const rate = writable();
export const user = writable();
export const selectedRate = writable();
diff --git a/src/lib/upload.js b/src/lib/upload.js
index 6354b7f4..0e8a2908 100644
--- a/src/lib/upload.js
+++ b/src/lib/upload.js
@@ -1,5 +1,5 @@
export const upload = async (file, type, progress, token) => {
- console.log("FILE", file)
+ console.log('FILE', file);
let url = `/api/upload/${type}`;
let formData = new FormData();
formData.append('file', file);
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 54e965d9..76ce5077 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -9,6 +9,17 @@ export function scroll(section) {
const base = browser ? '' : env.PUBLIC_COINOS_URL;
+export const g = (url, fetch, headers) =>
+ fetch(base + url, { headers })
+ .then((r) => r.text())
+ .then((body) => {
+ try {
+ return JSON.parse(body);
+ } catch (e) {
+ throw new Error(body);
+ }
+ });
+
export const get = (url, headers = {}) =>
fetch(base + url, { headers })
.then((r) => r.text())