diff --git a/web/src/components/donate/DonateOptionsCard.svelte b/web/src/components/donate/DonateOptionsCard.svelte index 95f152a6..1ce362f9 100644 --- a/web/src/components/donate/DonateOptionsCard.svelte +++ b/web/src/components/donate/DonateOptionsCard.svelte @@ -11,65 +11,65 @@ import { donate } from "$lib/env"; - let customInputValue: number; + let customInputValue: number | null; - const donateStripe = (amount: number) => { - const url = new URL(donate.stripe); - url.searchParams.set("__prefilled_amount", (amount * 100).toString()); - window.open(url, "_blank"); + type Processor = "stripe" | "liberapay"; + let processor: Processor = "stripe"; + + const donationMethods: Record void> = { + stripe: (amount: number) => { + const url = new URL(donate.stripe); + url.searchParams.set("__prefilled_amount", amount.toString()); + window.open(url, "_blank"); + }, + liberapay: (amount: number) => { + const url = new URL(donate.liberapay); + url.searchParams.set("currency", "USD"); + url.searchParams.set("period", "monthly"); + url.searchParams.set("amount", (amount / 100).toString()); + window.open(url, "_blank"); + } }; - const donateLibera = (amount: number) => { - const url = new URL(donate.liberapay); - url.searchParams.set("currency", "USD"); - url.searchParams.set("period", "monthly"); - url.searchParams.set("amount", (amount / 100).toString()); - window.open(url, "_blank"); - }; - - const toClipboard = (text: string) => navigator.clipboard.writeText(text); + const send = (amount: number) => { + return donationMethods[processor](amount); + }
- -
- donateStripe(5)} - > + - donateStripe(10)} - > + - donateStripe(15)} - > + - donateStripe(30)} - > +
diff --git a/web/src/components/donate/DonationOption.svelte b/web/src/components/donate/DonationOption.svelte index c0988c90..9692ee91 100644 --- a/web/src/components/donate/DonationOption.svelte +++ b/web/src/components/donate/DonationOption.svelte @@ -1,7 +1,9 @@