| 1 | import { useState } from "react"; |
| 2 | import { useAuth } from "../../../context/Auth"; |
| 3 | import { useAppSelector } from "../../../redux/hooks"; |
| 4 | import { getLocalStorage, setLocalStorage } from "../../../util/localStorage"; |
| 5 | import Alert from "../../gui/Alert"; |
| 6 | import { ReusableCard } from "../../ReusableCard"; |
| 7 | import { TabTitle } from "../components/OnboardingCardTabs"; |
| 8 | import OnboardingLocalTab from "../components/OnboardingLocalTab"; |
| 9 | import { useOnboardingCard } from "../hooks"; |
| 10 | import MainTab from "./tabs/main"; |
| 11 | |
| 12 | export interface OnboardingCardState { |
| 13 | show?: boolean; |
| 14 | activeTab?: TabTitle; |
| 15 | } |
| 16 | |
| 17 | interface OnboardingCardProps { |
| 18 | isDialog: boolean; |
| 19 | } |
| 20 | |
| 21 | export function PlatformOnboardingCard({ isDialog }: OnboardingCardProps) { |
| 22 | const onboardingCard = useOnboardingCard(); |
| 23 | const config = useAppSelector((store) => store.config.config); |
| 24 | const auth = useAuth(); |
| 25 | const [currentTab, setCurrentTab] = useState<"main" | "local">("main"); |
| 26 | |
| 27 | if (getLocalStorage("onboardingStatus") === undefined) { |
| 28 | setLocalStorage("onboardingStatus", "Started"); |
| 29 | } |
| 30 | |
| 31 | function onGetStarted() { |
| 32 | auth.login(true).then((success) => { |
| 33 | if (success) { |
| 34 | onboardingCard.close(isDialog); |
| 35 | } |
| 36 | }); |
| 37 | } |
| 38 | |
| 39 | return ( |
| 40 | <ReusableCard |
| 41 | showCloseButton={!isDialog && !!config.modelsByRole.chat.length} |
| 42 | onClose={() => onboardingCard.close()} |
| 43 | > |
| 44 | <div className="flex h-full w-full items-center justify-center"> |
| 45 | {currentTab === "main" ? ( |
| 46 | <MainTab |
| 47 | onRemainLocal={() => setCurrentTab("local")} |
| 48 | isDialog={isDialog} |
| 49 | /> |
| 50 | ) : ( |
| 51 | <div className="mt-4 flex flex-col"> |
| 52 | <Alert type="info"> |
| 53 | By choosing this option, Continue will be configured by a local |
| 54 | config.yaml file. If you're just looking to use Ollama and still |
| 55 | want to manage your configuration through Continue, click{" "} |
| 56 | <a href="#" onClick={onGetStarted}> |
| 57 | here |
| 58 | </a> |
| 59 | </Alert> |
| 60 | <OnboardingLocalTab isDialog={isDialog} /> |
| 61 | </div> |
| 62 | )} |
| 63 | </div> |
| 64 | </ReusableCard> |
| 65 | ); |
| 66 | } |