π Open source, privacy-first web analytics β a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Move DashboardLockedBanner to header
Blue Mousee01c14cb3a7d
diff --git a/web/app/components/DashboardLockedBanner.tsx b/web/app/components/DashboardLockedBanner.tsxdeleted file mode 100644index 1c0267691..000000000--- a/web/app/components/DashboardLockedBanner.tsx+++ /dev/null@@ -1,82 +0,0 @@-import { LockClosedIcon } from '@heroicons/react/24/outline'-import { memo, useState, useMemo } from 'react'-import { useTranslation } from 'react-i18next'--import { DashboardBlockReason } from '~/lib/models/User'-import { useAuth } from '~/providers/AuthProvider'-import Modal from '~/ui/Modal'--const DashboardLockedBanner = () => {- const { t } = useTranslation('common')- const { user } = useAuth()- const [showMoreInfoModal, setShowMoreInfoModal] = useState(false)-- const dashboardBlockReason = user?.dashboardBlockReason-- const message = useMemo(() => {- if (dashboardBlockReason === DashboardBlockReason.exceeding_plan_limits) {- return t('project.locked.descExceedingTier')- }- if (dashboardBlockReason === DashboardBlockReason.trial_ended) {- return t('project.locked.descTialEnded')- }- if (dashboardBlockReason === DashboardBlockReason.payment_failed) {- return t('project.locked.descPaymentFailed')- }- if (dashboardBlockReason === DashboardBlockReason.subscription_cancelled) {- return t('project.locked.descSubCancelled')- }- }, [t, dashboardBlockReason])-- if (!dashboardBlockReason) {- return null- }-- return (- <>- <div className='bg-yellow-400 dark:bg-yellow-500'>- <div className='mx-auto max-w-7xl px-3 py-3 sm:px-6 lg:px-8'>- <div className='flex flex-wrap items-center justify-between'>- <div className='flex flex-1 items-center'>- <span className='flex rounded-lg bg-yellow-600 p-2'>- <LockClosedIcon- className='h-6 w-6 text-white'- aria-hidden='true'- />- </span>- <p className='ml-3 font-medium text-black'>- {t('dashboard.accountLocked')}- </p>- </div>- <div className='order-3 mt-2 w-full shrink-0 sm:order-2 sm:mt-0 sm:w-auto'>- <span- onClick={() => setShowMoreInfoModal(true)}- className='flex cursor-pointer items-center justify-center rounded-md bg-gray-50 px-4 py-2 text-sm font-medium text-yellow-600 hover:bg-yellow-50 dark:bg-slate-800 dark:text-gray-50 dark:hover:bg-slate-700'- >- {t('common.learnMore')}- </span>- </div>- </div>- </div>- </div>- <Modal- onClose={() => setShowMoreInfoModal(false)}- onSubmit={() => setShowMoreInfoModal(false)}- submitText={t('common.gotIt')}- title={t('dashboard.accountLockedTitle')}- message={- <span>- {message}- <br />- <br />- {t('project.locked.resolve')}- </span>- }- type='warning'- isOpened={showMoreInfoModal}- />- </>- )-}--export default memo(DashboardLockedBanner)diff --git a/web/app/components/Header/index.tsx b/web/app/components/Header/index.tsxindex ea7258b63..868b1ebef 100644--- a/web/app/components/Header/index.tsx+++ b/web/app/components/Header/index.tsx@@ -36,7 +36,7 @@ import {PuzzleIcon,PhoneIcon,} from 'lucide-react'-import { memo, Fragment, useMemo, useState, useEffect } from 'react'+import { memo, Fragment, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { Link } from 'react-router'@@ -49,10 +49,12 @@ import {DOCS_URL,isDisableMarketingPages,} from '~/lib/constants'+import { DashboardBlockReason } from '~/lib/models/User'import { useAuth } from '~/providers/AuthProvider'import { useTheme } from '~/providers/ThemeProvider'import Flag from '~/ui/Flag'import SwetrixLogo from '~/ui/icons/SwetrixLogo'+import Modal from '~/ui/Modal'import routes from '~/utils/routes'dayjs.extend(utc)@@ -403,7 +405,97 @@ const Separator = () => (</svg>)-const TrialBanner = () => {+interface TrialBannerProps {+ status: string | null+ rawStatus: number | null+}++const TrialBanner = ({ status, rawStatus }: TrialBannerProps) => {+ const { t } = useTranslation('common')++ return (+ <div className='w-full bg-slate-900 text-gray-100 dark:bg-slate-800/70'>+ <div className='mx-auto max-w-7xl px-4 py-2 text-center text-sm sm:px-6 lg:px-8'>+ <span className='font-medium'>{status}</span>+ <span className='mx-1.5'>β</span>+ <Link to={routes.billing} className='font-semibold underline'>+ {t('header.trialBanner.pickAPlan')}+ </Link>+ <span className='ml-1.5'>+ {rawStatus === TRIAL_STATUS_MAPPING.ENDED+ ? t('header.trialBanner.keepUsingEnded')+ : t('header.trialBanner.keepUsing')}+ </span>+ </div>+ </div>+ )+}++const DashboardLockedBanner = () => {+ const { t } = useTranslation('common')+ const { user } = useAuth()+ const [showMoreInfoModal, setShowMoreInfoModal] = useState(false)++ const dashboardBlockReason = user?.dashboardBlockReason++ const message = useMemo(() => {+ if (dashboardBlockReason === DashboardBlockReason.exceeding_plan_limits) {+ return t('project.locked.descExceedingTier')+ }+ if (dashboardBlockReason === DashboardBlockReason.trial_ended) {+ return t('project.locked.descTialEnded')+ }+ if (dashboardBlockReason === DashboardBlockReason.payment_failed) {+ return t('project.locked.descPaymentFailed')+ }+ if (dashboardBlockReason === DashboardBlockReason.subscription_cancelled) {+ return t('project.locked.descSubCancelled')+ }+ }, [t, dashboardBlockReason])++ return (+ <>+ <div className='w-full bg-amber-500 text-gray-50'>+ <div className='mx-auto max-w-7xl space-x-2 px-4 py-2 text-center text-sm sm:px-6 lg:px-8'>+ <span>{t('dashboard.accountLocked')}</span>+ <button+ type='button'+ onClick={() => setShowMoreInfoModal(true)}+ className='rounded-md bg-slate-100 px-2 py-0.5 font-medium text-gray-900'+ >+ {t('common.learnMore')}+ </button>+ </div>+ </div>+ <Modal+ onClose={() => setShowMoreInfoModal(false)}+ closeText={t('common.close')}+ title={t('dashboard.accountLockedTitle')}+ message={+ <span>+ {message}+ <br />+ <br />+ {t('project.locked.resolve')}+ </span>+ }+ type='warning'+ isOpened={showMoreInfoModal}+ customButtons={+ <Link+ to={routes.billing}+ onClick={() => setShowMoreInfoModal(false)}+ className='inline-flex w-full justify-center rounded-md bg-indigo-600 px-4 py-2 text-base font-medium text-white transition-colors hover:bg-indigo-700 sm:ml-3 sm:w-auto sm:text-sm'+ >+ {t('main.goToBilling')}+ </Link>+ }+ />+ </>+ )+}++const BannerManager = () => {const { t } = useTranslation('common')const { user, isAuthenticated } = useAuth()@@ -450,179 +542,24 @@ const TrialBanner = () => {]}, [user, t])- const blackFridayBannerVisible = useMemo(() => {- const now = dayjs.utc()- const diff = BLACK_FRIDAY_END.diff(now)-- return diff > 0- }, [])-- if (- !status ||- isSelfhosted ||- !isAuthenticated ||- !['none', 'trial'].includes(user?.planCode || '') ||- blackFridayBannerVisible- ) {- return null+ const trialBannerHidden = useMemo(() => {+ return (+ !status ||+ isSelfhosted ||+ !isAuthenticated ||+ !['none', 'trial'].includes(user?.planCode || '')+ )+ }, [status, isAuthenticated, user?.planCode])++ if (!trialBannerHidden) {+ return <TrialBanner status={status} rawStatus={rawStatus} />}- return (- <div className='w-full bg-slate-900 text-gray-100 dark:bg-slate-900'>- <div className='mx-auto max-w-7xl px-4 py-2 text-center text-sm sm:px-6 lg:px-8'>- <span className='font-medium'>{status}</span>- <span className='mx-1.5'>β</span>- <Link to={routes.billing} className='font-semibold underline'>- {t('header.trialBanner.pickAPlan')}- </Link>- <span className='ml-1.5'>- {rawStatus === TRIAL_STATUS_MAPPING.ENDED- ? t('header.trialBanner.keepUsingEnded')- : t('header.trialBanner.keepUsing')}- </span>- </div>- </div>- )-}--const BLACK_FRIDAY_END = dayjs.utc('2025-12-03T00:00:00')--const BlackFridayBanner = () => {- const { user, isAuthenticated } = useAuth()- const [timeLeft, setTimeLeft] = useState<{- days: number- hours: number- minutes: number- seconds: number- } | null>(null)-- useEffect(() => {- const calculateTimeLeft = () => {- const now = dayjs.utc()- const diff = BLACK_FRIDAY_END.diff(now)-- if (diff <= 0) {- setTimeLeft(null)- return- }-- const duration = dayjs.duration(diff)- setTimeLeft({- days: Math.floor(duration.asDays()),- hours: duration.hours(),- minutes: duration.minutes(),- seconds: duration.seconds(),- })- }-- calculateTimeLeft()- const interval = setInterval(calculateTimeLeft, 1000)-- return () => clearInterval(interval)- }, [])-- const shouldShow = useMemo(() => {- if (isSelfhosted) return false- if (!timeLeft) return false-- if (!isAuthenticated) return true-- const eligiblePlans = ['free', 'none', 'trial']- return eligiblePlans.includes(user?.planCode || '')- }, [isAuthenticated, user, timeLeft])-- if (!shouldShow || !timeLeft) return null-- return (- <Link- to={routes.billing}- className='relative block w-full overflow-hidden bg-gradient-to-r from-slate-950 via-purple-950 to-slate-950'- >- <div className='absolute inset-0 hidden overflow-hidden sm:block'>- <div className='absolute top-1 left-[10%] h-1 w-1 animate-pulse rounded-full bg-yellow-400/60' />- <div className='absolute top-3 left-[25%] h-0.5 w-0.5 animate-pulse rounded-full bg-amber-300/50 [animation-delay:200ms]' />- <div className='absolute top-1 left-[50%] h-1 w-1 animate-pulse rounded-full bg-orange-400/60 [animation-delay:400ms]' />- <div className='absolute top-2 left-[75%] h-0.5 w-0.5 animate-pulse rounded-full bg-yellow-300/50 [animation-delay:600ms]' />- <div className='absolute top-1 left-[90%] h-1 w-1 animate-pulse rounded-full bg-amber-400/60 [animation-delay:800ms]' />- </div>-- {/* Mobile layout - compact, wraps if needed */}- <div className='relative flex flex-wrap items-center justify-center gap-x-2 gap-y-1 px-3 py-1.5 sm:hidden'>- <span className='flex items-center gap-2 text-sm text-white/90'>- Get- </span>- <span className='rounded bg-gradient-to-r from-amber-500 to-orange-500 px-1.5 py-0.5 text-xs font-bold text-white'>- 50% OFF- </span>- <div className='flex items-center gap-2 text-sm text-white/90'>- with the code:- </div>- <code className='rounded bg-black/40 px-1.5 py-0.5 font-mono text-xs font-bold text-amber-400'>- BLACKFRIDAY- </code>- <span className='font-mono text-xs text-white/80'>- {String(timeLeft.days).padStart(2, '0')}:- {String(timeLeft.hours).padStart(2, '0')}:- {String(timeLeft.minutes).padStart(2, '0')}:- {String(timeLeft.seconds).padStart(2, '0')}- </span>- </div>-- {/* Desktop layout - wraps if needed */}- <div className='relative mx-auto hidden max-w-7xl flex-wrap items-center justify-center gap-x-6 gap-y-1 px-6 py-2 sm:flex lg:px-8'>- <div className='flex items-center gap-2'>- <span className='bg-gradient-to-r from-amber-400 via-orange-400 to-red-500 bg-clip-text text-lg font-black tracking-tight text-transparent'>- β‘ BLACK FRIDAY SALE β‘- </span>- </div>-- <div className='flex items-center gap-2 text-sm text-white/90'>- <span>Get</span>- <span className='rounded-md bg-gradient-to-r from-amber-500 to-orange-500 px-2 py-0.5 text-sm font-bold text-white shadow-lg shadow-orange-500/25'>- 50% OFF- </span>- <span>your first month</span>- </div>-- <div className='flex items-center gap-2 text-sm'>- <span className='text-white/70'>Code:</span>- <code className='rounded border border-amber-500/30 bg-black/40 px-2 py-0.5 font-mono font-bold text-amber-400'>- BLACKFRIDAY- </code>- </div>-- <div className='flex items-center gap-2'>- <span className='text-xs text-white/60'>Ends in:</span>- <div className='flex items-center gap-1 font-mono text-sm font-bold'>- <span className='rounded bg-white/10 px-1.5 py-0.5 text-white'>- {String(timeLeft.days).padStart(2, '0')}- <span className='text-xs text-white/60'>d</span>- </span>- <span className='text-white/40'>:</span>- <span className='rounded bg-white/10 px-1.5 py-0.5 text-white'>- {String(timeLeft.hours).padStart(2, '0')}- <span className='text-xs text-white/60'>h</span>- </span>- <span className='text-white/40'>:</span>- <span className='rounded bg-white/10 px-1.5 py-0.5 text-white'>- {String(timeLeft.minutes).padStart(2, '0')}- <span className='text-xs text-white/60'>m</span>- </span>- <span className='text-white/40'>:</span>- <span className='rounded bg-white/10 px-1.5 py-0.5 text-white'>- {String(timeLeft.seconds).padStart(2, '0')}- <span className='text-xs text-white/60'>s</span>- </span>- </div>- </div>+ if (user?.dashboardBlockReason) {+ return <DashboardLockedBanner />+ }- <span className='group flex items-center gap-1 rounded-full bg-gradient-to-r from-amber-500 to-orange-500 px-4 py-1.5 text-sm font-semibold text-white shadow-lg shadow-orange-500/25 transition-all hover:shadow-orange-500/40'>- Claim offer- <ArrowRightIcon className='h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5' />- </span>- </div>- </Link>- )+ return null}const AuthedHeader = ({@@ -634,7 +571,6 @@ const AuthedHeader = ({colourBackground: booleanopenMenu: () => void}) => {- const { user } = useAuth()const { t } = useTranslation('common')return (@@ -653,15 +589,6 @@ const AuthedHeader = ({</Link><div className='ml-10 hidden gap-4 space-x-1 lg:flex'>- {user?.planCode === 'none' ? (- <Link- to={routes.billing}- className='underline-animate text-base leading-6 font-semibold text-rose-600 focus:outline-hidden'- key='NoSubscription'- >- {t('billing.inactive')}- </Link>- ) : null}{!isSelfhosted && !isDisableMarketingPages ? (<SolutionsMenu />) : null}@@ -831,8 +758,7 @@ const Header = ({ refPage, transparent }: HeaderProps) => {return (<Popover>- <BlackFridayBanner />- <TrialBanner />+ <BannerManager />{/* Computer / Laptop / Tablet layout header */}{isAuthenticated ? (@@ -965,18 +891,6 @@ const Header = ({ refPage, transparent }: HeaderProps) => {) : null}{!isSelfhosted &&isAuthenticated &&- user?.planCode === 'none' ? (- <Link- to={routes.billing}- onClick={() => setMobileMenuOpen(false)}- className='-mx-3 block rounded-lg px-3 py-2 text-base leading-7 font-semibold text-rose-600 hover:bg-gray-400/20 dark:hover:bg-slate-700/50'- key='NoSubscription'- >- {t('billing.inactive')}- </Link>- ) : null}- {!isSelfhosted &&- isAuthenticated &&user?.planCode !== 'none' &&user?.planCode !== 'trial' ? (<Linkdiff --git a/web/app/pages/Billing/index.tsx b/web/app/pages/Billing/index.tsxindex 478992ac4..708126033 100644--- a/web/app/pages/Billing/index.tsx+++ b/web/app/pages/Billing/index.tsx@@ -11,7 +11,6 @@ import { useTranslation, Trans } from 'react-i18next'import { useLoaderData, useFetcher } from 'react-router'import { toast } from 'sonner'-import DashboardLockedBanner from '~/components/DashboardLockedBanner'import FAQ from '~/components/marketing/FAQ'import BillingPricing from '~/components/pricing/BillingPricing'import {@@ -207,8 +206,6 @@ const Billing = () => {return (<div className='min-h-page bg-gray-50 dark:bg-slate-900'>- <DashboardLockedBanner />-<div className='mx-auto px-4 pt-12 whitespace-pre-line sm:px-6 md:w-11/12'><h1 className='text-4xl font-extrabold text-gray-900 dark:text-gray-50'>{t('billing.title')}diff --git a/web/app/pages/Dashboard/Dashboard.tsx b/web/app/pages/Dashboard/Dashboard.tsxindex 97d43fe73..1c918e7a4 100644--- a/web/app/pages/Dashboard/Dashboard.tsx+++ b/web/app/pages/Dashboard/Dashboard.tsx@@ -22,7 +22,6 @@ import {} from 'react-router'import { toast } from 'sonner'-import DashboardLockedBanner from '~/components/DashboardLockedBanner'import EventsRunningOutBanner from '~/components/EventsRunningOutBanner'import {useLiveVisitorsProxy,@@ -346,7 +345,6 @@ const Dashboard = () => {<><div className='min-h-min-footer bg-gray-50 dark:bg-slate-900'><EventsRunningOutBanner />- <DashboardLockedBanner /><div className='flex flex-col'><div className='mx-auto w-full max-w-7xl px-4 py-6 sm:px-6 lg:px-8'><div className='mb-4 flex flex-wrap justify-between gap-2'>