diff --git a/refact-agent/gui/src/components/Buttons/Buttons.tsx b/refact-agent/gui/src/components/Buttons/Buttons.tsx index 59f2b3e10..550f8ffb6 100644 --- a/refact-agent/gui/src/components/Buttons/Buttons.tsx +++ b/refact-agent/gui/src/components/Buttons/Buttons.tsx @@ -1,4 +1,4 @@ -import React, { forwardRef, useCallback } from "react"; +import React, { forwardRef } from "react"; import { IconButton, Button, Flex } from "@radix-ui/themes"; import { PaperPlaneIcon, @@ -8,9 +8,6 @@ import { } from "@radix-ui/react-icons"; import classNames from "classnames"; import styles from "./button.module.css"; -import { useOpenUrl } from "../../hooks/useOpenUrl"; -import { useAppSelector } from "../../hooks"; -import { selectApiKey } from "../../features/Config/configSlice"; import { PuzzleIcon } from "../../images/PuzzleIcon"; type IconButtonProps = React.ComponentProps; @@ -78,95 +75,3 @@ export const RightButtonGroup: React.FC = ( /> ); }; - -type AgentUsageLinkButtonProps = ButtonProps & { - href?: string; - onClick?: () => void; - target?: HTMLFormElement["target"]; - isPlanFree?: boolean; - children?: React.ReactNode; - disabled?: boolean; -}; - -const SUBSCRIPTION_URL = - // "https://refact.smallcloud.ai/refact/update-subscription"; - "https://app.refact.ai/my-workspace"; - -// const SUBSCRIPTION_FALLBACK_URL = "https://refact.smallcloud.ai/"; -const SUBSCRIPTION_FALLBACK_URL = "https://app.refact.ai/"; - -export const AgentUsageLinkButton: React.FC = ({ - href, - isPlanFree, - children, - onClick, - disabled, - ...rest -}) => { - const openUrl = useOpenUrl(); - const apiKey = useAppSelector(selectApiKey); - const [isLoading, setIsLoading] = React.useState(false); - const [error, setError] = React.useState(null); - - const fetchSubscriptionUrl = useCallback(async (): Promise => { - try { - const response = await fetch(SUBSCRIPTION_URL, { - method: "GET", - headers: { - Authorization: `Bearer ${apiKey}`, - }, - }); - - if (!response.ok) { - openUrl(SUBSCRIPTION_FALLBACK_URL); - return null; - } - - const data = (await response.json()) as { url: string }; - return data.url; - } catch (e) { - openUrl(SUBSCRIPTION_FALLBACK_URL); - return null; - } - }, [apiKey, openUrl]); - - const handleClick = useCallback( - async (event: React.FormEvent) => { - event.preventDefault(); - - if (isLoading) return; - - try { - setIsLoading(true); - setError(null); - - if (href && isPlanFree) { - openUrl(href); - } else if (isPlanFree !== undefined && !isPlanFree) { - const url = await fetchSubscriptionUrl(); - if (url) { - openUrl(url); - } - } - - onClick?.(); - } catch (err) { - // eslint-disable-next-line no-console - console.error("Error in LinkButton:", err); - setError(err instanceof Error ? err.message : "An error occurred"); - } finally { - setIsLoading(false); - } - }, - [href, isPlanFree, onClick, openUrl, fetchSubscriptionUrl, isLoading], - ); - - return ( -
void handleClick(event)}> - - {error &&
{error}
} -
- ); -}; diff --git a/refact-agent/gui/src/components/Buttons/index.tsx b/refact-agent/gui/src/components/Buttons/index.tsx index 34c081aae..a3474e6a3 100644 --- a/refact-agent/gui/src/components/Buttons/index.tsx +++ b/refact-agent/gui/src/components/Buttons/index.tsx @@ -4,8 +4,6 @@ export { BackToSideBarButton, RightButton, RightButtonGroup, - AgentUsageLinkButton, - AgentIntegrationsButton, } from "./Buttons"; // export { ThinkingButton } from "./ThinkingButton"; diff --git a/refact-agent/gui/src/components/Toolbar/Dropdown.tsx b/refact-agent/gui/src/components/Toolbar/Dropdown.tsx index dd586597a..ae371e867 100644 --- a/refact-agent/gui/src/components/Toolbar/Dropdown.tsx +++ b/refact-agent/gui/src/components/Toolbar/Dropdown.tsx @@ -90,10 +90,7 @@ export const Dropdown: React.FC = ({ const host = useAppSelector(selectHost); const dispatch = useAppDispatch(); const ballance = useCoinBallance(); - const coinBallance = ballance?.have_coins_exactly ?? 0; - // TODO: check how much of this is still used. - // const { maxAgentUsageAmount, currentAgentUsage } = useAgentUsage(); const isWorkspaceSelectionSkipped = useAppSelector( selectIsSkippedWorkspaceSelection,