mirror of https://github.com/VERT-sh/VERT.git
fix: defer loading stripe
This commit is contained in:
parent
2f5fddcc6e
commit
58cdaad889
|
@ -23,11 +23,8 @@
|
||||||
import Panel from "$lib/components/visual/Panel.svelte";
|
import Panel from "$lib/components/visual/Panel.svelte";
|
||||||
import { effects } from "$lib/store/index.svelte";
|
import { effects } from "$lib/store/index.svelte";
|
||||||
import { addToast } from "$lib/store/ToastProvider";
|
import { addToast } from "$lib/store/ToastProvider";
|
||||||
import {
|
import { loadStripe } from "@stripe/stripe-js/pure";
|
||||||
loadStripe,
|
import { type Stripe, type StripeElements } from "@stripe/stripe-js";
|
||||||
type Stripe,
|
|
||||||
type StripeElements,
|
|
||||||
} from "@stripe/stripe-js";
|
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import {
|
import {
|
||||||
CalendarHeartIcon,
|
CalendarHeartIcon,
|
||||||
|
@ -67,10 +64,7 @@
|
||||||
|
|
||||||
if (!res.ok) {
|
if (!res.ok) {
|
||||||
paymentState = "prepay";
|
paymentState = "prepay";
|
||||||
addToast(
|
addToast("error", m["about.donate.payment_error"]());
|
||||||
"error",
|
|
||||||
m["about.donate.payment_error"](),
|
|
||||||
);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +82,6 @@
|
||||||
const payDuration = 400;
|
const payDuration = 400;
|
||||||
const transition = "cubic-bezier(0.23, 1, 0.320, 1)";
|
const transition = "cubic-bezier(0.23, 1, 0.320, 1)";
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
stripe = await loadStripe(PUB_STRIPE_KEY);
|
|
||||||
});
|
|
||||||
|
|
||||||
const donate = async () => {
|
const donate = async () => {
|
||||||
if (!stripe || !clientSecret || !elements) return;
|
if (!stripe || !clientSecret || !elements) return;
|
||||||
|
|
||||||
|
@ -104,7 +94,7 @@
|
||||||
"error",
|
"error",
|
||||||
m["about.donate.payment_failed"]({
|
m["about.donate.payment_failed"]({
|
||||||
message: submitResult.error.message || "",
|
message: submitResult.error.message || "",
|
||||||
period
|
period,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
enablePay = true;
|
enablePay = true;
|
||||||
|
@ -126,7 +116,7 @@
|
||||||
"error",
|
"error",
|
||||||
m["about.donate.payment_failed"]({
|
m["about.donate.payment_failed"]({
|
||||||
message: res.error.message || "",
|
message: res.error.message || "",
|
||||||
period
|
period,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@ -152,10 +142,7 @@
|
||||||
addToast("success", m["about.donate.thank_you"]());
|
addToast("success", m["about.donate.thank_you"]());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
addToast(
|
addToast("error", m["about.donate.donation_error"]());
|
||||||
"error",
|
|
||||||
m["about.donate.donation_error"](),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
goto("/about");
|
goto("/about");
|
||||||
|
@ -298,7 +285,9 @@
|
||||||
class="btn w-full h-12 bg-accent-red text-black rounded-full mt-4"
|
class="btn w-full h-12 bg-accent-red text-black rounded-full mt-4"
|
||||||
onclick={donate}
|
onclick={donate}
|
||||||
>
|
>
|
||||||
{m["about.donate.donate_amount"]({ amount: amount.toFixed(2) })}
|
{m["about.donate.donate_amount"]({
|
||||||
|
amount: amount.toFixed(2),
|
||||||
|
})}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue