diff --git a/src/lib/components/bottomModalAlert.svelte b/src/lib/components/bottomModalAlert.svelte index fca8ab7a5..e3fafcba6 100644 --- a/src/lib/components/bottomModalAlert.svelte +++ b/src/lib/components/bottomModalAlert.svelte @@ -9,6 +9,9 @@ dismissBottomModalAlert, hideAllModalAlerts } from '$lib/stores/bottom-alerts'; + import { organization } from '$lib/stores/organization'; + import { BillingPlan } from '$lib/constants'; + import { upgradeURL } from '$lib/stores/billing'; let currentIndex = 0; let openModalOnMobile = false; @@ -19,7 +22,8 @@ $: currentModalAlert = filteredModalAlerts[currentIndex] as BottomModalAlertItem; - function handleClose(modalAlert: BottomModalAlertItem) { + function handleClose() { + const modalAlert = currentModalAlert; dismissBottomModalAlert(modalAlert.id); hideNotification(modalAlert.id); if (modalAlert.closed) modalAlert.closed(); @@ -38,14 +42,28 @@ function showPrevious() { currentIndex = (currentIndex - 1 + filteredModalAlerts.length) % filteredModalAlerts.length; } + + function showUpgrade() { + const plan = currentModalAlert.plan; + const organizationPlan = $organization.billingPlan; + switch (plan) { + case 'free': + return false; + case 'pro': + return organizationPlan === BillingPlan.FREE; + case 'scale': + return organizationPlan === BillingPlan.FREE || organizationPlan === BillingPlan.PRO; + } + } {#if filteredModalAlerts.length > 0 && currentModalAlert} + {@const shouldShowUpgrade = showUpgrade()}
{#key currentModalAlert.id} - {#if currentModalAlert.learnMore && currentModalAlert.learnMore.link} @@ -160,7 +179,7 @@
{#if currentModalAlert.learnMore && currentModalAlert.learnMore.link} @@ -245,7 +264,7 @@