Open History to see the last commit
1import type { ApprovalRequestId, ProviderApprovalDecision } 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: ApprovalRequestId | null;
10 readonly onRespond: (
11 requestId: ApprovalRequestId,
12 decision: ProviderApprovalDecision,
13 ) => Promise<unknown>;
14}
15
16export function PendingApprovalCard(props: PendingApprovalCardProps) {
17 return (
18 <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">
19 <Text className="font-t3-bold text-2xs uppercase tracking-[1.1px] text-sky-700 dark:text-sky-300">
20 Approval needed
21 </Text>
22 <Text className="font-t3-bold text-lg text-neutral-950 dark:text-neutral-50">
23 {props.approval.requestKind}
24 </Text>
25 {props.approval.detail ? (
26 <Text className="font-sans text-sm leading-5 text-neutral-600 dark:text-neutral-400">
27 {props.approval.detail}
28 </Text>
29 ) : null}
30 <View className="flex-row flex-wrap gap-2.5">
31 <Pressable
32 className="items-center justify-center rounded-[14px] bg-blue-500 px-3.5 py-3"
33 disabled={props.respondingApprovalId === props.approval.requestId}
34 onPress={() => void props.onRespond(props.approval.requestId, "accept")}
35 >
36 <Text className="font-t3-extrabold text-sm text-white">Allow once</Text>
37 </Pressable>
38 <Pressable
39 className="items-center justify-center rounded-[14px] bg-neutral-200 px-3.5 py-3 dark:bg-neutral-800"
40 disabled={props.respondingApprovalId === props.approval.requestId}
41 onPress={() => void props.onRespond(props.approval.requestId, "acceptForSession")}
42 >
43 <Text className="font-t3-bold text-sm text-neutral-950 dark:text-neutral-50">
44 Allow session
45 </Text>
46 </Pressable>
47 <Pressable
48 className="items-center justify-center rounded-[14px] bg-rose-100 px-3.5 py-3 dark:bg-rose-500/18"
49 disabled={props.respondingApprovalId === props.approval.requestId}
50 onPress={() => void props.onRespond(props.approval.requestId, "decline")}
51 >
52 <Text className="font-t3-bold text-sm text-rose-700 dark:text-rose-300">Decline</Text>
53 </Pressable>
54 </View>
55 </View>
56 );
57}