From 86cd647a8818fc377464fa23bc834a6d9050da2e Mon Sep 17 00:00:00 2001 From: Darshan Date: Mon, 24 Nov 2025 17:42:39 +0530 Subject: [PATCH] address comments. --- src/lib/stores/billing.ts | 15 --------------- src/lib/stores/headerAlert.ts | 9 +++++++++ src/lib/studio/studio-widget.ts | 7 ++----- 3 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/lib/stores/billing.ts b/src/lib/stores/billing.ts index 611e83b98..89a547377 100644 --- a/src/lib/stores/billing.ts +++ b/src/lib/stores/billing.ts @@ -294,21 +294,6 @@ export function isServiceLimited(serviceId: PlanServices, plan: Tier, total: num return isLimited && total >= limit && !hasUsageFees; } -export function calculateEnterpriseTrial(org: Organization) { - if (!org || !org.billingNextInvoiceDate) return 0; - const endDate = new Date(org.billingNextInvoiceDate); - const startDate = new Date(org.billingCurrentInvoiceDate); - const today = new Date(); - - let diffCycle = endDate.getTime() - startDate.getTime(); - diffCycle = Math.ceil(diffCycle / (1000 * 60 * 60 * 24)); - if (diffCycle === 14) { - const remaining = endDate.getTime() - today.getTime(); - return Math.ceil(remaining / (1000 * 60 * 60 * 24)); - } - return 0; -} - export function calculateTrialDay(org: Organization) { if (isFreePlan(org?.billingPlan)) return false; const endDate = new Date(org?.billingStartDate); diff --git a/src/lib/stores/headerAlert.ts b/src/lib/stores/headerAlert.ts index 6accad1f7..48d1f0c0c 100644 --- a/src/lib/stores/headerAlert.ts +++ b/src/lib/stores/headerAlert.ts @@ -47,6 +47,15 @@ function createHeaderAlertStore() { return n; }); return component as HeaderAlert; + }, + isShowing: (): boolean => { + let showing = false; + update((n) => { + if (n.components.length === 0) return n; + showing = n.components.some((c) => c.show); + return n; + }); + return showing; } }; } diff --git a/src/lib/studio/studio-widget.ts b/src/lib/studio/studio-widget.ts index 2f841eaf4..ce737af36 100644 --- a/src/lib/studio/studio-widget.ts +++ b/src/lib/studio/studio-widget.ts @@ -8,6 +8,7 @@ import DEV_CSS_URL from '@imagine.dev/web-components/imagine-web-components.css? import { getSessionId } from '$lib/sentry'; import type * as WebComponentsType from '@imagine.dev/web-components/web-components'; import * as Sentry from '@sentry/sveltekit'; +import { headerAlert } from '$lib/stores/headerAlert'; const COMPONENT_SELECTOR = 'imagine-web-components-wrapper[data-appwrite-studio]'; const STYLE_ATTRIBUTE = 'data-appwrite-studio-style'; @@ -30,10 +31,6 @@ function hasDocument(): boolean { return typeof document !== 'undefined'; } -function hasBannerAttached(): boolean { - return !!document.querySelector('section.alert'); -} - function disableBodyScroll() { if (!hasDocument() || scrollLocked) { return; @@ -199,7 +196,7 @@ function updatePosition() { return; } - const bannerOffset = hasBannerAttached() ? BLOCK_BANNER_OFFSET : 0; + const bannerOffset = headerAlert.isShowing() ? BLOCK_BANNER_OFFSET : 0; const rect = anchorElement.getBoundingClientRect(); const { offsetX, offsetY } = currentOptions;