| 1 | import type { ServerProvider } from "@t3tools/contracts"; |
| 2 | import { CHATGPT_USAGE_URL, usesChatGptSharing } from "@t3tools/shared/usageLimits"; |
| 3 | import { Alert, Linking, Pressable, View } from "react-native"; |
| 4 | import { AppText as Text } from "../../components/AppText"; |
| 5 | import { ProviderIcon } from "../../components/ProviderIcon"; |
| 6 | |
| 7 | export function ChatGptSharingStatus({ provider }: { provider: ServerProvider | null }) { |
| 8 | if (!usesChatGptSharing(provider)) return null; |
| 9 | return ( |
| 10 | <View className="flex-row items-center justify-between gap-3 px-3 py-1"> |
| 11 | <Pressable |
| 12 | accessibilityRole="button" |
| 13 | accessibilityLabel="ChatGPT token sharing is active" |
| 14 | className="min-h-11 flex-row items-center gap-2" |
| 15 | onPress={() => { |
| 16 | Alert.alert( |
| 17 | "ChatGPT sharing is on", |
| 18 | [ |
| 19 | provider?.auth.email, |
| 20 | "Eligible usage uses your ChatGPT plan. Credit settings and limits are managed in ChatGPT.", |
| 21 | ] |
| 22 | .filter(Boolean) |
| 23 | .join("\n\n"), |
| 24 | ); |
| 25 | }} |
| 26 | > |
| 27 | <ProviderIcon provider="codex" size={14} /> |
| 28 | <Text className="text-xs text-foreground-muted">Using ChatGPT plan</Text> |
| 29 | </Pressable> |
| 30 | <Pressable |
| 31 | accessibilityRole="link" |
| 32 | className="min-h-11 justify-center" |
| 33 | onPress={() => void Linking.openURL(CHATGPT_USAGE_URL).catch(() => undefined)} |
| 34 | > |
| 35 | <Text className="text-xs font-t3-medium text-primary">Manage usage</Text> |
| 36 | </Pressable> |
| 37 | </View> |
| 38 | ); |
| 39 | } |