From 3f60b98036e62e30db3626e3cece989ee36d7b49 Mon Sep 17 00:00:00 2001 From: Darshan Date: Thu, 3 Apr 2025 10:04:58 +0530 Subject: [PATCH 1/3] fix: change-plan from account. --- src/lib/components/support.svelte | 22 +++++++--- .../change-plan/+page.svelte | 43 +++++++++++-------- 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/src/lib/components/support.svelte b/src/lib/components/support.svelte index d28cce1032..2791d7b733 100644 --- a/src/lib/components/support.svelte +++ b/src/lib/components/support.svelte @@ -5,17 +5,29 @@ import { isSupportOnline, showSupportModal } from '$routes/(console)/wizard/support/store'; import { trackEvent } from '$lib/actions/analytics'; import { localeShortTimezoneName, utcHourToLocaleHour } from '$lib/helpers/date'; - import { upgradeURL } from '$lib/stores/billing'; + import { plansInfo } from '$lib/stores/billing'; import { Card } from '$lib/components/index'; import { app } from '$lib/stores/app'; - import { currentPlan } from '$lib/stores/organization'; + import { currentPlan, organizationList } from '$lib/stores/organization'; import { isCloud } from '$lib/system'; + import { base } from '$app/paths'; export let show = false; export let showHeader = true; - $: hasPremiumSupport = $currentPlan?.premiumSupport ?? false; + $: hasPremiumSupport = $currentPlan?.premiumSupport ?? areAllOrganizationsPaid ?? false; + + $: areAllOrganizationsPaid = $organizationList.teams.every( + (team) => $plansInfo.get(team['billingPlan'])?.premiumSupport + ); + + // there can only be one free organization + $: freeOrganization = $organizationList.teams.find( + (team) => !$plansInfo.get(team['billingPlan'])?.premiumSupport + ); + + $: upgradeURL = `${base}/organization-${freeOrganization.$id}/change-plan`; $: supportTimings = `${utcHourToLocaleHour('16:00')} - ${utcHourToLocaleHour('00:00')} ${localeShortTimezoneName()}`; @@ -54,7 +66,7 @@ } ]; - const showCloudSupport = (index) => { + const showCloudSupport = (index: number) => { return (index === 0 && isCloud) || index > 0; }; @@ -82,7 +94,7 @@
{#if !hasPremiumSupport}