| 1 | import { ChevronRightIcon } from "@heroicons/react/24/outline"; |
| 2 | import { useContext } from "react"; |
| 3 | import { Button, ButtonSubtext } from "../../.."; |
| 4 | import { useAuth } from "../../../../context/Auth"; |
| 5 | import { IdeMessengerContext } from "../../../../context/IdeMessenger"; |
| 6 | import { selectCurrentOrg } from "../../../../redux"; |
| 7 | import { useAppSelector } from "../../../../redux/hooks"; |
| 8 | import { hasPassedFTL } from "../../../../util/freeTrial"; |
| 9 | import ContinueLogo from "../../../gui/ContinueLogo"; |
| 10 | import { useOnboardingCard } from "../../hooks"; |
| 11 | |
| 12 | export default function MainTab({ |
| 13 | onRemainLocal, |
| 14 | isDialog, |
| 15 | }: { |
| 16 | onRemainLocal: () => void; |
| 17 | isDialog: boolean; |
| 18 | }) { |
| 19 | const ideMessenger = useContext(IdeMessengerContext); |
| 20 | const onboardingCard = useOnboardingCard(); |
| 21 | const auth = useAuth(); |
| 22 | const currentOrg = useAppSelector(selectCurrentOrg); |
| 23 | |
| 24 | function onGetStarted() { |
| 25 | auth.login(true).then((success) => { |
| 26 | if (success) { |
| 27 | onboardingCard.close(isDialog); |
| 28 | } |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | function openPastFreeTrialOnboarding() { |
| 33 | ideMessenger.post("controlPlane/openUrl", { |
| 34 | path: "setup-models", |
| 35 | orgSlug: currentOrg?.slug, |
| 36 | }); |
| 37 | onboardingCard.close(isDialog); |
| 38 | } |
| 39 | |
| 40 | const pastFreeTrialLimit = hasPassedFTL(); |
| 41 | |
| 42 | return ( |
| 43 | <div className="xs:px-0 flex w-full max-w-full flex-col items-center justify-center px-4 text-center"> |
| 44 | <div className="xs:flex hidden"> |
| 45 | <ContinueLogo height={75} /> |
| 46 | </div> |
| 47 | |
| 48 | {pastFreeTrialLimit ? ( |
| 49 | <> |
| 50 | <p className="xs:w-3/4 w-full text-sm"> |
| 51 | You've reached the free trial limit. Visit the Continue Platform to |
| 52 | select a Coding Assistant. |
| 53 | </p> |
| 54 | <Button |
| 55 | onClick={openPastFreeTrialOnboarding} |
| 56 | className="mt-4 grid w-full grid-flow-col items-center gap-2" |
| 57 | > |
| 58 | Go to Continue Platform |
| 59 | </Button> |
| 60 | </> |
| 61 | ) : onboardingCard.activeTab === "ExistingUserHubIntro" ? ( |
| 62 | <> |
| 63 | <p className="xs:w-3/4 w-full text-sm"> |
| 64 | You can now browse and create custom AI code assistants at{" "} |
| 65 | <code>hub.continue.dev</code> |
| 66 | </p> |
| 67 | |
| 68 | <Button |
| 69 | onClick={onGetStarted} |
| 70 | className="mt-4 grid w-full grid-flow-col items-center gap-2" |
| 71 | > |
| 72 | Get started |
| 73 | </Button> |
| 74 | </> |
| 75 | ) : ( |
| 76 | <> |
| 77 | <p className="xs:w-3/4 w-full text-sm"> |
| 78 | Log in to quickly build your first custom AI code assistant |
| 79 | </p> |
| 80 | |
| 81 | <Button |
| 82 | onClick={onGetStarted} |
| 83 | className="mt-4 grid w-full grid-flow-col items-center gap-2" |
| 84 | > |
| 85 | Get started |
| 86 | </Button> |
| 87 | </> |
| 88 | )} |
| 89 | |
| 90 | {onboardingCard.activeTab === "ExistingUserHubIntro" ? ( |
| 91 | <ButtonSubtext onClick={() => onboardingCard.close(isDialog)}> |
| 92 | <div className="mt-4 flex cursor-pointer items-center justify-center gap-1"> |
| 93 | <span>Or, use Continue as usual</span> |
| 94 | <ChevronRightIcon className="h-3 w-3" /> |
| 95 | </div> |
| 96 | </ButtonSubtext> |
| 97 | ) : ( |
| 98 | <ButtonSubtext onClick={onRemainLocal}> |
| 99 | <div className="flex cursor-pointer items-center justify-center gap-1 hover:brightness-125"> |
| 100 | <span>Or, remain local</span> |
| 101 | <ChevronRightIcon className="h-3 w-3" /> |
| 102 | </div> |
| 103 | </ButtonSubtext> |
| 104 | )} |
| 105 | </div> |
| 106 | ); |
| 107 | } |