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

PendingApprovalCard.tsx

59 lines2.7 KB

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>;
15​
16export function PendingApprovalCard(props: PendingApprovalCardProps) {
17 // Opaque for the same reason as PendingUserInputCard: nothing blurs the feed
18 // behind this card, so a translucent surface bleeds messages through it.
19 return (
20 <View className="gap-2.5 rounded-[20px] border border-neutral-200 bg-neutral-100 p-4 dark:border-white/6 dark:bg-neutral-900">
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-normal text-neutral-600 dark:text-neutral-400">
29 {props.approval.detail}
30 </Text>
31 ) : null}
32 <View className="flex-row flex-wrap gap-2.5">
33 <Pressable
34 className="items-center justify-center rounded-[14px] bg-blue-500 px-3.5 py-3"
35 disabled={props.respondingApprovalId === props.approval.requestId}
36 onPress={() => void props.onRespond(props.approval.requestId, "accept")}
37 >
38 <Text className="font-t3-extrabold text-sm text-white">Allow once</Text>
39 </Pressable>
40 <Pressable
41 className="items-center justify-center rounded-[14px] bg-neutral-200 px-3.5 py-3 dark:bg-neutral-800"
42 disabled={props.respondingApprovalId === props.approval.requestId}
43 onPress={() => void props.onRespond(props.approval.requestId, "acceptForSession")}
44 >
45 <Text className="font-t3-bold text-sm text-neutral-950 dark:text-neutral-50">
46 Allow session
47 </Text>
48 </Pressable>
49 <Pressable
50 className="items-center justify-center rounded-[14px] bg-rose-100 px-3.5 py-3 dark:bg-rose-500/18"
51 disabled={props.respondingApprovalId === props.approval.requestId}
52 onPress={() => void props.onRespond(props.approval.requestId, "decline")}
53 >
54 <Text className="font-t3-bold text-sm text-rose-700 dark:text-rose-300">Decline</Text>
55 </Pressable>
56 </View>
57 </View>
58 );