All files / src/components/settings AiHydroAccountInfoCard.tsx

0% Statements 0/23
0% Branches 0/1
0% Functions 0/1
0% Lines 0/23

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                                             
import { EmptyRequest } from "@shared/proto/cline/common"
import { VSCodeButton } from "@vscode/webview-ui-toolkit/react"
import { useAiHydroAuth } from "@/context/AiHydroAuthContext"
import { useExtensionState } from "@/context/ExtensionStateContext"
import { AccountServiceClient } from "@/services/grpc-client"
 
export const AiHydroAccountInfoCard = () => {
	const { aihydroUser } = useAiHydroAuth()
	const { navigateToAccount } = useExtensionState()
 
	const user = aihydroUser || undefined
 
	const handleLogin = () => {
		AccountServiceClient.accountLoginClicked(EmptyRequest.create()).catch((err) =>
			console.error("Failed to get login URL:", err),
		)
	}
 
	const handleShowAccount = () => {
		navigateToAccount()
	}
 
	return (
		<div className="max-w-[600px]">
			{user ? (
				<VSCodeButton appearance="secondary" onClick={handleShowAccount}>
					View Billing & Usage
				</VSCodeButton>
			) : (
				<div>
					<VSCodeButton className="mt-0" onClick={handleLogin}>
						Sign Up with AI-Hydro
					</VSCodeButton>
				</div>
			)}
		</div>
	)
}