Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

ChatGptSharingControl.tsx

37 lines1.5 KB

1import { usesChatGptSharing } from "@t3tools/shared/usageLimits";
2import type { ServerProvider } from "@t3tools/contracts";
3import { T, useGT } from "gt-react";
4import { useId } from "react";
5import { OpenAI } from "../Icons";
6import { ChatGptUsageButton } from "../settings/ChatGptUsageButton";
7import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
8​
9export function ChatGptSharingControl({ provider }: { provider: ServerProvider | null }) {
10 const speedNoticeId = useId();
11 const gt = useGT();
12 const speedNotice = gt`Fast and Ultrafast are unavailable with this ChatGPT connection. Use an existing Codex CLI login for speed options your account supports.`;
13 if (!usesChatGptSharing(provider)) return null;
14 return (
15 <div className="flex items-center justify-between gap-4 border-t px-3 py-2">
16 <Tooltip>
17 <TooltipTrigger
18 render={
19 <span
20 aria-describedby={speedNoticeId}
21 tabIndex={0}
22 className="flex items-center gap-2 rounded-sm text-xs text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring"
23 />
24 }
25 >
26 <OpenAI className="size-3.5" aria-hidden="true" />
27 <T>Using ChatGPT plan</T>
28 </TooltipTrigger>
29 <span id={speedNoticeId} className="sr-only">
30 {speedNotice}
31 </span>
32 <TooltipPopup side="top">{speedNotice}</TooltipPopup>
33 </Tooltip>
34 <ChatGptUsageButton size="xs" />
35 </div>
36 );