From 4dd3b28ca79ee18eb5d11f1d32581f88574f7615 Mon Sep 17 00:00:00 2001 From: Arman Date: Mon, 17 Jul 2023 20:52:23 +0200 Subject: [PATCH] fix: errors when stripe key is missing --- src/lib/stores/billing.ts | 4 ---- src/lib/system.ts | 4 +++- src/routes/console/account/payments/+page.svelte | 3 ++- .../console/account/payments/paymentModal.svelte | 10 +++------- .../organization-[organization]/billing/store.ts | 2 -- src/routes/console/wizard/step2.svelte | 6 ++++-- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 609c613eb..abca418c4 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -430,10 +430,6 @@ export class Billing { // } } -export const publicStripeKey = import.meta.env?.VITE_STRIPE_PUBLIC_KEY?.toString() as - | string - | undefined; - export const tierFree = { price: 0, name: 'Free', diff --git a/src/lib/system.ts b/src/lib/system.ts index 69bd7d2cc..cca9b13c8 100644 --- a/src/lib/system.ts +++ b/src/lib/system.ts @@ -11,7 +11,8 @@ export const VARS = { CONSOLE_MODE: import.meta.env?.VITE_CONSOLE_MODE?.toString() as string | undefined, CONSOLE_TIER: import.meta.env?.VITE_CONSOLE_TIER?.toString() as string | undefined, VERCEL_ENV: import.meta.env?.VITE_VERCEL_ENV?.toString() as string | undefined, - GOOGLE_ANALYTICS: import.meta.env?.VITE_GA_PROJECT?.toString() as string | undefined + GOOGLE_ANALYTICS: import.meta.env?.VITE_GA_PROJECT?.toString() as string | undefined, + STRIPE_PUBLIC_KEY: import.meta.env?.VITE_STRIPE_PUBLIC_KEY?.toString() as string | undefined }; export const ENV = { @@ -24,3 +25,4 @@ export const ENV = { export const MODE = VARS.CONSOLE_MODE === Mode.CLOUD ? Mode.CLOUD : Mode.SELF_HOSTED; export const isCloud = MODE === Mode.CLOUD; export const isSelfHosted = MODE === Mode.SELF_HOSTED; +export const hasStripePublicKey = !!VARS.STRIPE_PUBLIC_KEY; diff --git a/src/routes/console/account/payments/+page.svelte b/src/routes/console/account/payments/+page.svelte index 624d7c0cd..bea1c3dd1 100644 --- a/src/routes/console/account/payments/+page.svelte +++ b/src/routes/console/account/payments/+page.svelte @@ -1,6 +1,7 @@