mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
We want more customers to upgrade their instances to Micro on paid plans. - Only dismiss for 7 days at a time per project - Render it if available, not only when there's a performance related reason
18 lines
627 B
TypeScript
18 lines
627 B
TypeScript
import dayjs from 'dayjs'
|
|
|
|
export const FREE_MICRO_UPGRADE_BANNER_SNOOZE_DAYS = 7
|
|
|
|
/**
|
|
* The banner stays hidden for a fixed window after it was dismissed, then resurfaces.
|
|
* An unparseable or missing timestamp (e.g. a legacy boolean value) counts as not dismissed.
|
|
*/
|
|
export const isFreeMicroUpgradeBannerSnoozed = (
|
|
dismissedAt: string | null | undefined,
|
|
now: dayjs.ConfigType = dayjs()
|
|
) => {
|
|
if (typeof dismissedAt !== 'string') return false
|
|
const dismissed = dayjs(dismissedAt)
|
|
if (!dismissed.isValid()) return false
|
|
return dayjs(now).diff(dismissed, 'day', true) < FREE_MICRO_UPGRADE_BANNER_SNOOZE_DAYS
|
|
}
|