diff options
| author | Adam Soltys <[email protected]> | 2025-07-08 10:16:22 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-08 10:16:22 -0700 |
| commit | 2d9d01d6e8d63ee223078874aa3b101b016367ac (patch) | |
| tree | 0a5a7d90c15aadcd22a75e65aafa2c69287442c0 /src/routes/(app)/send/invoice | |
| parent | 3c63c47f51f0b86f530ce2381a44a05cb1e4abf1 (diff) | |
| download | coinos-ui-2d9d01d6e8d63ee223078874aa3b101b016367ac.tar.gz coinos-ui-2d9d01d6e8d63ee223078874aa3b101b016367ac.zip | |
auto pay
Diffstat (limited to 'src/routes/(app)/send/invoice')
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.ts | 14 | ||||
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.svelte | 21 |
2 files changed, 31 insertions, 4 deletions
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.ts b/src/routes/(app)/send/invoice/[id]/+page.server.ts index 3ef933d4..4bb7ded5 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.ts +++ b/src/routes/(app)/send/invoice/[id]/+page.server.ts @@ -2,11 +2,19 @@ import getRates from "$lib/rates"; import { auth, fd, get, post, types } from "$lib/utils"; import { error, redirect } from "@sveltejs/kit"; -export async function load({ cookies, params: { id }, parent }) { +export async function load({ cookies, depends, params: { id }, parent }) { + depends("app:trust"); const { user } = await parent(); const aid = cookies.get("aid") || user.id; - const invoice = await get(`/invoice/${id}`); + let invoice = await get(`/invoice/${id}`); + + const trust = await get("/trust", auth(cookies)); + const trusted = trust.includes(invoice.uid); + if (trusted) { + const p = await post("/payments", invoice, auth(cookies)); + redirect(307, `/sent/${p.id}`); + } if (invoice.amount && invoice.prompt && invoice.tip === null) redirect(307, `/invoice/${id}/tip`); @@ -31,7 +39,7 @@ export async function load({ cookies, params: { id }, parent }) { const invoiceRate = rates[invoice.currency]; const { balance } = await get(`/account/${aid}`, auth(cookies)); - return { balance, invoice, user, rate, invoiceRate }; + return { balance, invoice, user, rate, invoiceRate, trusted }; } export const actions = { diff --git a/src/routes/(app)/send/invoice/[id]/+page.svelte b/src/routes/(app)/send/invoice/[id]/+page.svelte index 7d167f41..9aac5c8d 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.svelte +++ b/src/routes/(app)/send/invoice/[id]/+page.svelte @@ -1,4 +1,5 @@ <script> + import { invalidate } from "$app/navigation"; import { untrack } from "svelte"; import handler from "$lib/handler"; import { onDestroy, onMount } from "svelte"; @@ -26,7 +27,7 @@ } from "$lib/utils"; let { data, form } = $props(); - let { balance, invoice, user } = $state(data); + let { trusted, balance, invoice, user } = $state(data); let { address, hash, payreq, user: recipient, tip } = $state(invoice); let { currency } = $derived(user); let locale = $derived(loc(user)); @@ -64,6 +65,19 @@ }); }; + let toggleTrust = async (e) => { + e.preventDefault(); + e.stopPropagation(); + + if (trusted) { + await post("/post/trust/delete", { id: recipient.id }); + } else { + await post("/post/trust", { id: recipient.id }); + } + + invalidate("app:trust"); + }; + $effect(() => { if (form?.message?.includes("pin")) $pin = undefined; submitting = false; @@ -193,5 +207,10 @@ <button type="button" class="btn" onclick={external} >{$t("payments.moreOptions")}</button > + <button type="button" class="btn" onclick={toggleTrust}> + <iconify-icon icon={trusted ? "ph:star-fill" : "ph:star-bold"} width={32} + ></iconify-icon> + {$t("payments.trustUser")}</button + > </form> </div> |
