Skip to content

Commit dcaae5e

Browse files
chore(web): Update activation code text to use upsell dialog
1 parent d195ad4 commit dcaae5e

1 file changed

Lines changed: 19 additions & 60 deletions

File tree

packages/web/src/app/(app)/settings/license/activationCodeCard.tsx

Lines changed: 19 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,17 @@ import { Input } from "@/components/ui/input";
55
import { Button } from "@/components/ui/button";
66
import { LoadingButton } from "@/components/ui/loading-button";
77
import { SettingsCard } from "../components/settingsCard";
8-
import { activateLicense, createCheckoutSession } from "@/ee/features/lighthouse/actions";
8+
import { activateLicense } from "@/ee/features/lighthouse/actions";
99
import { isServiceError } from "@/lib/utils";
1010
import { useToast } from "@/components/hooks/use-toast";
1111
import { Separator } from "@/components/ui/separator";
12-
import { Loader2, ExternalLink } from "lucide-react";
13-
import { useOffers } from "@/ee/features/lighthouse/useOffers";
14-
import { Skeleton } from "@/components/ui/skeleton";
12+
import { UpsellDialog } from "@/ee/features/lighthouse/upsellDialog";
1513

1614
export function ActivationCodeCard() {
1715
const [activationCode, setActivationCode] = useState("");
1816
const [isActivating, setIsActivating] = useState(false);
19-
const [isCheckoutSessionCreating, setIsCheckoutSessionCreating] = useState(false);
17+
const [isUpsellOpen, setIsUpsellOpen] = useState(false);
2018
const { toast } = useToast();
21-
const { data: offers, isPending, isError } = useOffers();
2219

2320
const handleActivate = useCallback(() => {
2421
if (!activationCode.trim()) {
@@ -45,36 +42,6 @@ export function ActivationCodeCard() {
4542
});
4643
}, [activationCode, toast]);
4744

48-
const onCreateCheckoutSession = useCallback((isTrialEligible: boolean) => {
49-
setIsCheckoutSessionCreating(true);
50-
51-
createCheckoutSession({
52-
requestTrial: isTrialEligible,
53-
source: "license_settings"
54-
})
55-
.then((response) => {
56-
if (isServiceError(response)) {
57-
toast({
58-
description: `Failed to start checkout: ${response.message}`,
59-
variant: "destructive",
60-
});
61-
} else {
62-
// Stripe Checkout is an external URL; use assign for a
63-
// full navigation rather than router.push.
64-
window.location.assign(response.url);
65-
}
66-
})
67-
.catch(() => {
68-
toast({
69-
description: "Failed to start checkout. Please try again.",
70-
variant: "destructive",
71-
});
72-
})
73-
.finally(() => {
74-
setIsCheckoutSessionCreating(false);
75-
});
76-
}, [toast]);
77-
7845
return (
7946
<SettingsCard>
8047
<div className="flex flex-col gap-2">
@@ -106,32 +73,24 @@ export function ActivationCodeCard() {
10673
Activate
10774
</LoadingButton>
10875
</div>
109-
{
110-
isPending ? (
111-
<Skeleton className="h-5 w-80" />
112-
) : isError ? (
113-
<span className="text-destructive text-sm">Failed to load pricing information.</span>
114-
) : (
115-
<p className="text-sm text-muted-foreground flex items-center gap-1.5">
116-
Don&apos;t have an activation code?
117-
<Button
118-
variant="link"
119-
className="h-auto p-0 gap-1"
120-
onClick={() => onCreateCheckoutSession(offers.trial.eligible)}
121-
disabled={isCheckoutSessionCreating}
122-
>
123-
{offers.trial.eligible ? "Start a free trial" : "Purchase a license"}
124-
{isCheckoutSessionCreating ? (
125-
<Loader2 className="h-3 w-3 animate-spin" />
126-
) : (
127-
<ExternalLink className="h-3 w-3" />
128-
)}
129-
</Button>
130-
</p>
131-
)
132-
}
76+
<p className="text-sm text-muted-foreground flex items-center gap-1.5">
77+
Don&apos;t have an activation code?
78+
<Button
79+
variant="link"
80+
className="h-auto p-0"
81+
onClick={() => setIsUpsellOpen(true)}
82+
>
83+
See plans
84+
</Button>
85+
</p>
13386
</div>
13487
</div>
88+
<UpsellDialog
89+
open={isUpsellOpen}
90+
onOpenChange={setIsUpsellOpen}
91+
source="license_settings"
92+
returnPath="/settings/license"
93+
/>
13594
</SettingsCard>
13695
);
13796
}

0 commit comments

Comments
 (0)