Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

594 B
Raw Blame
"use client";

import useWorkspace from "@/lib/swr/use-workspace";

export function useDashboardBannerVisible() {
  const {
    exceededEvents,
    exceededLinks,
    paymentFailedAt,
    subscriptionCanceledAt,
    loading,
  } = useWorkspace();

  const subscriptionCanceled =
    subscriptionCanceledAt && new Date(subscriptionCanceledAt) < new Date();

  const isUpgradeBannerVisible =
    (exceededEvents ||
      exceededLinks ||
      !!paymentFailedAt ||
      subscriptionCanceled) &&
    !loading;

  return {
    isUpgradeBannerVisible,
    hasBanner: isUpgradeBannerVisible,
  };
}