From 9fbea4a38059db9a38837d3c41e3ca3484cba7cc Mon Sep 17 00:00:00 2001 From: miloschwartz Date: Sun, 26 Oct 2025 17:12:47 -0700 Subject: [PATCH] move enterprise/subscription required alert to component --- src/app/[orgId]/settings/general/page.tsx | 19 ++----------- src/components/SecurityFeaturesAlert.tsx | 33 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 src/components/SecurityFeaturesAlert.tsx diff --git a/src/app/[orgId]/settings/general/page.tsx b/src/app/[orgId]/settings/general/page.tsx index 45d3c397..d96dbb65 100644 --- a/src/app/[orgId]/settings/general/page.tsx +++ b/src/app/[orgId]/settings/general/page.tsx @@ -52,8 +52,7 @@ import { build } from "@server/build"; import { SwitchInput } from "@app/components/SwitchInput"; import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext"; import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext"; -import { Badge } from "@app/components/ui/badge"; -import { Alert, AlertDescription } from "@app/components/ui/alert"; +import { SecurityFeaturesAlert } from "@app/components/SecurityFeaturesAlert"; // Session length options in hours const SESSION_LENGTH_OPTIONS = [ @@ -347,21 +346,7 @@ export default function GeneralPage() { - {build == "saas" && !subscriptionStatus?.isSubscribed() ? ( - - - {t("subscriptionRequiredToUse")} - - - ) : null} - - {build == "enterprise" && !isUnlocked() ? ( - - - {t("licenseRequiredToUse")} - - - ) : null} +
diff --git a/src/components/SecurityFeaturesAlert.tsx b/src/components/SecurityFeaturesAlert.tsx new file mode 100644 index 00000000..2531659b --- /dev/null +++ b/src/components/SecurityFeaturesAlert.tsx @@ -0,0 +1,33 @@ +"use client"; +import { Alert, AlertDescription } from "@app/components/ui/alert"; +import { build } from "@server/build"; +import { useTranslations } from "next-intl"; +import { useLicenseStatusContext } from "@app/hooks/useLicenseStatusContext"; +import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext"; + +export function SecurityFeaturesAlert() { + const t = useTranslations(); + const { isUnlocked } = useLicenseStatusContext(); + const subscriptionStatus = useSubscriptionStatusContext(); + + return ( + <> + {build === "saas" && !subscriptionStatus?.isSubscribed() ? ( + + + {t("subscriptionRequiredToUse")} + + + ) : null} + + {build === "enterprise" && !isUnlocked() ? ( + + + {t("licenseRequiredToUse")} + + + ) : null} + + ); +} +