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

ChatGptSharingStatus.tsx

48 lines1.9 KB

1import * as Dialog from "../../components/ui/Dialog";
2import type { ServerProvider } from "@t3tools/contracts";
3import { CHATGPT_USAGE_URL, usesChatGptSharing } from "@t3tools/shared/usageLimits";
4import { T, useGT } from "gt-react-native";
5import { Pressable, View } from "react-native";
6import { tryOpenExternalUrl } from "../../lib/openExternalUrl";
7import { AppText as Text } from "../../components/ui/AppText";
8import { ProviderIcon } from "../../components/ProviderIcon";
9​
10export function ChatGptSharingStatus({ provider }: { provider: ServerProvider | null }) {
11 const gt = useGT();
12 if (!usesChatGptSharing(provider)) return null;
13 return (
14 <View className="flex-row items-center justify-between gap-3 px-3 py-1">
15 <Pressable
16 accessibilityRole="button"
17 accessibilityLabel={gt`ChatGPT token sharing is active`}
18 className="min-h-11 flex-row items-center gap-2"
19 onPress={() => {
20 Dialog.alert(
21 gt`ChatGPT sharing is on`,
22 [
23 provider?.auth.email,
24 gt`Eligible usage uses your ChatGPT plan. Credit settings and limits are managed in ChatGPT.`,
25 gt`Fast and Ultrafast are unavailable with this ChatGPT connection. Use an existing Codex CLI login for speed options your account supports.`,
26 ]
27 .filter(Boolean)
28 .join("\n\n"),
29 );
30 }}
31 >
32 <ProviderIcon provider="codex" size={14} />
33 <Text className="text-xs text-foreground-muted">
34 <T>Using ChatGPT plan</T>
35 </Text>
36 </Pressable>
37 <Pressable
38 accessibilityRole="link"
39 className="min-h-11 justify-center"
40 onPress={() => void tryOpenExternalUrl(CHATGPT_USAGE_URL)}
41 >
42 <Text className="text-xs font-t3-medium text-primary">
43 <T>Manage usage</T>
44 </Text>
45 </Pressable>
46 </View>
47 );