Elffuss BraidHub

kikocis/continue public

98d59da7cd9c 路 3.3 KiBRawPermalink
1import { useContext } from "react";
2import { Button, SecondaryButton } from "../..";
3import { useAuth } from "../../../context/Auth";
4import { IdeMessengerContext } from "../../../context/IdeMessenger";
5import { useAppDispatch, useAppSelector } from "../../../redux/hooks";
6import { selectCurrentOrg } from "../../../redux/slices/profilesSlice";
7import { selectFirstHubProfile } from "../../../redux/thunks/selectFirstHubProfile";
8import { hasPassedFTL } from "../../../util/freeTrial";
9import { ToolTip } from "../../gui/Tooltip";
10import ContinueLogo from "../../svg/ContinueLogo";
11import { useOnboardingCard } from "../hooks/useOnboardingCard";
12
13export function OnboardingCardLanding({
14 onSelectConfigure,
15 isDialog,
16}: {
17 onSelectConfigure: () => void;
18 isDialog?: boolean;
19}) {
20 const ideMessenger = useContext(IdeMessengerContext);
21 const onboardingCard = useOnboardingCard();
22 const auth = useAuth();
23 const currentOrg = useAppSelector(selectCurrentOrg);
24 const dispatch = useAppDispatch();
25
26 function onGetStarted() {
27 void auth.login(true).then((success) => {
28 if (success) {
29 onboardingCard.close(isDialog);
30
31 // A new assistant is created when the account is created
32 // We want to switch to this immediately
33 void dispatch(selectFirstHubProfile());
34
35 ideMessenger.post("showTutorial", undefined);
36 ideMessenger.post("showToast", ["info", "馃帀 Welcome to Continue!"]);
37 }
38 });
39 }
40
41 function openPastFreeTrialOnboarding() {
42 ideMessenger.post("controlPlane/openUrl", {
43 path: "setup-models",
44 orgSlug: currentOrg?.slug,
45 });
46 onboardingCard.close(isDialog);
47 }
48
49 const pastFreeTrialLimit = hasPassedFTL();
50
51 return (
52 <div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center">
53 <div className="xs:flex hidden">
54 <ContinueLogo height={75} />
55 </div>
56
57 {pastFreeTrialLimit ? (
58 <>
59 <p className="xs:w-3/4 w-full text-sm">
60 You've reached the free trial limit. Visit the Continue Platform to
61 select a Coding Agent.
62 </p>
63 <Button
64 onClick={openPastFreeTrialOnboarding}
65 className="mt-4 grid w-full grid-flow-col items-center gap-2"
66 >
67 Go to Continue Platform
68 </Button>
69 </>
70 ) : (
71 <>
72 <p className="mb-5 mt-0 w-full text-sm">
73 Log in to access a free trial of the
74 <br />
75 <ToolTip
76 place="bottom"
77 content="Free trial includes 50 Chat requests and 2,000 autocomplete requests"
78 >
79 <span
80 className="cursor-pointer underline hover:brightness-125"
81 onClick={() =>
82 ideMessenger.post("controlPlane/openUrl", {
83 path: "pricing",
84 })
85 }
86 >
87 Models Add-On
88 </span>
89 </ToolTip>
90 </p>
91
92 <Button
93 onClick={onGetStarted}
94 className="mt-4 grid w-full grid-flow-col items-center gap-2"
95 >
96 Log in to Continue Hub
97 </Button>
98 </>
99 )}
100
101 <SecondaryButton onClick={onSelectConfigure} className="w-full">
102 Or, configure your own models
103 </SecondaryButton>
104 </div>
105 );
106}