fix: local storage state for free trial exit
This commit is contained in:
parent
f74a99c06e
commit
a5a1b14d60
3 changed files with 16 additions and 10 deletions
|
|
@ -4,6 +4,7 @@ import { useContext } from "react";
|
|||
import { Button, SecondaryButton, vscButtonBackground } from ".";
|
||||
import { IdeMessengerContext } from "../context/IdeMessenger";
|
||||
import { fontSize } from "../util";
|
||||
import { setLocalStorage } from "../util/localStorage";
|
||||
import { Listbox, ListboxButton, ListboxOptions, Transition } from "./ui";
|
||||
|
||||
interface ProgressBarProps {
|
||||
|
|
@ -79,6 +80,15 @@ export default function FreeTrialButton({
|
|||
}: FreeTrialButtonProps) {
|
||||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
|
||||
const onExitFreeTrial = async () => {
|
||||
setLocalStorage("hasExitedFreeTrial", true);
|
||||
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<Listbox>
|
||||
<div className="relative">
|
||||
|
|
@ -134,15 +144,7 @@ export default function FreeTrialButton({
|
|||
)}
|
||||
|
||||
<div className="mt-4 flex gap-2">
|
||||
<SecondaryButton
|
||||
className="flex-1"
|
||||
onClick={async () => {
|
||||
await ideMessenger.request("controlPlane/openUrl", {
|
||||
path: "setup-models",
|
||||
orgSlug: undefined,
|
||||
});
|
||||
}}
|
||||
>
|
||||
<SecondaryButton className="flex-1" onClick={onExitFreeTrial}>
|
||||
Exit trial
|
||||
</SecondaryButton>
|
||||
<Button
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import { ToolsSectionTooltip } from "../sections/tool-policies/ToolPoliciesSecti
|
|||
|
||||
import { usesFreeTrialApiKey } from "core/config/usesFreeTrialApiKey";
|
||||
import type { FreeTrialStatus } from "core/control-plane/client";
|
||||
import { getLocalStorage } from "../../../../util/localStorage";
|
||||
import { AssistantAndOrgListbox } from "../../../AssistantAndOrgListbox";
|
||||
|
||||
interface BlockSettingsToolbarIcon {
|
||||
|
|
@ -151,7 +152,8 @@ export function BlockSettingsTopToolbar() {
|
|||
|
||||
const [freeTrialStatus, setFreeTrialStatus] =
|
||||
useState<FreeTrialStatus | null>(null);
|
||||
const isUsingFreeTrial = usesFreeTrialApiKey(config);
|
||||
const hasExitedFreeTrial = getLocalStorage("hasExitedFreeTrial");
|
||||
const isUsingFreeTrial = usesFreeTrialApiKey(config) && !hasExitedFreeTrial;
|
||||
|
||||
useEffect(() => {
|
||||
const fetchFreeTrialStatus = () => {
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ type LocalStorageTypes = {
|
|||
showTutorialCard: boolean;
|
||||
shownProfilesIntroduction: boolean;
|
||||
disableIndexing: boolean;
|
||||
hasExitedFreeTrial: boolean;
|
||||
};
|
||||
|
||||
export enum LocalStorageKey {
|
||||
IsExploreDialogOpen = "isExploreDialogOpen",
|
||||
HasDismissedExploreDialog = "hasDismissedExploreDialog",
|
||||
HasExitedFreeTrial = "hasExitedFreeTrial",
|
||||
}
|
||||
|
||||
export function getLocalStorage<T extends keyof LocalStorageTypes>(
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue