Make paid feature

This commit is contained in:
Owen
2026-04-21 16:52:26 -07:00
parent 38f1387db1
commit 09744cf2f0

View File

@@ -31,6 +31,9 @@ import { createApiClient, formatAxiosError } from "@app/lib/api";
import { useEnvContext } from "@app/hooks/useEnvContext"; import { useEnvContext } from "@app/hooks/useEnvContext";
import { toast } from "@app/hooks/useToast"; import { toast } from "@app/hooks/useToast";
import { orgQueries } from "@app/lib/queries"; import { orgQueries } from "@app/lib/queries";
import { PaidFeaturesAlert } from "@app/components/PaidFeaturesAlert";
import { usePaidStatus } from "@app/hooks/usePaidStatus";
import { tierMatrix } from "@server/lib/billing/tierMatrix";
interface UptimeAlertSectionProps { interface UptimeAlertSectionProps {
orgId: string; orgId: string;
@@ -49,6 +52,8 @@ export default function UptimeAlertSection({
}: UptimeAlertSectionProps) { }: UptimeAlertSectionProps) {
const api = createApiClient(useEnvContext()); const api = createApiClient(useEnvContext());
const queryClient = useQueryClient(); const queryClient = useQueryClient();
const { isPaidUser } = usePaidStatus();
const isPaid = isPaidUser(tierMatrix.alertingRules);
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
const [name, setName] = useState(`${siteId ? "Site" : "Resource"} ${startingName} Alert`); const [name, setName] = useState(`${siteId ? "Site" : "Resource"} ${startingName} Alert`);
@@ -206,6 +211,12 @@ export default function UptimeAlertSection({
</CredenzaDescription> </CredenzaDescription>
</CredenzaHeader> </CredenzaHeader>
<CredenzaBody> <CredenzaBody>
<div className="space-y-4">
<PaidFeaturesAlert tiers={tierMatrix.alertingRules} />
<fieldset
disabled={!isPaid}
className={!isPaid ? "opacity-50 pointer-events-none" : ""}
>
<div className="space-y-4"> <div className="space-y-4">
<div className="space-y-2"> <div className="space-y-2">
<Label htmlFor="alert-name">Name</Label> <Label htmlFor="alert-name">Name</Label>
@@ -284,6 +295,8 @@ export default function UptimeAlertSection({
/> />
</div> </div>
</div> </div>
</fieldset>
</div>
</CredenzaBody> </CredenzaBody>
<CredenzaFooter> <CredenzaFooter>
<CredenzaClose asChild> <CredenzaClose asChild>
@@ -292,7 +305,7 @@ export default function UptimeAlertSection({
<Button <Button
onClick={handleSubmit} onClick={handleSubmit}
loading={loading} loading={loading}
disabled={loading} disabled={loading || !isPaid}
> >
Create Alert Create Alert
</Button> </Button>