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

PendingApprovalCard.tsx

65 lines2.8 KB

1import type { ProviderApprovalDecision, RuntimeRequestId } from "@t3tools/contracts";
2import { Pressable, View } from "react-native";
3​
4import { AppText as Text } from "../../components/AppText";
5import type { PendingApproval } from "../../lib/threadActivity";
6​
7export interface PendingApprovalCardProps {
8 readonly approval: PendingApproval;
9 readonly respondingApprovalId: RuntimeRequestId | null;
10 readonly onRespond: (
11 requestId: RuntimeRequestId,
12 decision: ProviderApprovalDecision,
13 ) => Promise<unknown>;
15​
16export function PendingApprovalCard(props: PendingApprovalCardProps) {
17 const canRespond = props.approval.responseCapability === "live";
18 const disabled = !canRespond || props.respondingApprovalId === props.approval.requestId;
19 return (
20 <View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100/80 p-4 dark:border-white/6 dark:bg-neutral-900/80">
21 <Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
22 Approval needed
23 </Text>
24 <Text className="font-t3-bold text-lg text-neutral-950 dark:text-neutral-50">
25 {props.approval.requestKind}
26 </Text>
27 {props.approval.detail ? (
28 <Text className="font-sans text-sm leading-5 text-neutral-600 dark:text-neutral-400">
29 {props.approval.detail}
30 </Text>
31 ) : null}
32 {!canRespond ? (
33 <Text className="font-sans text-sm leading-5 text-neutral-600 dark:text-neutral-400">
34 The provider process for this request is no longer available. Interrupt or restart the run
35 to continue.
36 </Text>
37 ) : null}
38 <View className="flex-row flex-wrap gap-2.5">
39 <Pressable
40 className="items-center justify-center rounded-[14px] bg-blue-500 px-3.5 py-3"
41 disabled={disabled}
42 onPress={() => void props.onRespond(props.approval.requestId, "accept")}
43 >
44 <Text className="font-t3-extrabold text-sm text-white">Allow once</Text>
45 </Pressable>
46 <Pressable
47 className="items-center justify-center rounded-[14px] bg-neutral-200 px-3.5 py-3 dark:bg-neutral-800"
48 disabled={disabled}
49 onPress={() => void props.onRespond(props.approval.requestId, "acceptForSession")}
50 >
51 <Text className="font-t3-bold text-sm text-neutral-950 dark:text-neutral-50">
52 Allow session
53 </Text>
54 </Pressable>
55 <Pressable
56 className="items-center justify-center rounded-[14px] bg-rose-100 px-3.5 py-3 dark:bg-rose-500/18"
57 disabled={disabled}
58 onPress={() => void props.onRespond(props.approval.requestId, "decline")}
59 >
60 <Text className="font-t3-bold text-sm text-rose-700 dark:text-rose-300">Decline</Text>
61 </Pressable>
62 </View>
63 </View>
64 );