1- import type { ApprovalRequestId , ProviderApprovalDecision } from "@t3tools/contracts" ;
1+ import type {
2+ ApprovalRequestId ,
3+ ProviderApprovalDecision ,
4+ ProviderApprovalOption ,
5+ } from "@t3tools/contracts" ;
26import { Pressable , View } from "react-native" ;
37
48import { AppText as Text } from "../../components/AppText" ;
@@ -13,7 +17,14 @@ export interface PendingApprovalCardProps {
1317 ) => Promise < unknown > ;
1418}
1519
20+ const DEFAULT_APPROVAL_OPTIONS = [
21+ { decision : "accept" , label : "Allow once" } ,
22+ { decision : "acceptForSession" , label : "Allow session" } ,
23+ { decision : "decline" , label : "Decline" } ,
24+ ] satisfies ReadonlyArray < ProviderApprovalOption > ;
25+
1626export function PendingApprovalCard ( props : PendingApprovalCardProps ) {
27+ const options = props . approval . options ?? DEFAULT_APPROVAL_OPTIONS ;
1728 // Opaque for the same reason as PendingUserInputCard: nothing blurs the feed
1829 // behind this card, so a translucent surface bleeds messages through it.
1930 return (
@@ -22,37 +33,40 @@ export function PendingApprovalCard(props: PendingApprovalCardProps) {
2233 Approval needed
2334 </ Text >
2435 < Text className = "font-t3-bold text-lg text-neutral-950 dark:text-neutral-50" >
25- { props . approval . requestKind }
36+ { props . approval . appName ?? props . approval . requestKind }
2637 </ Text >
2738 { props . approval . detail ? (
2839 < Text className = "font-sans text-sm leading-normal text-neutral-600 dark:text-neutral-400" >
2940 { props . approval . detail }
3041 </ Text >
3142 ) : null }
3243 < 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 >
44+ { options . map ( ( option ) => (
45+ < Pressable
46+ key = { option . decision }
47+ className = { `items-center justify-center rounded-[14px] px-3.5 py-3 ${
48+ option . decision === "accept"
49+ ? "bg-blue-500"
50+ : option . decision === "decline"
51+ ? "bg-rose-100 dark:bg-rose-500/18"
52+ : "bg-neutral-200 dark:bg-neutral-800"
53+ } `}
54+ disabled = { props . respondingApprovalId === props . approval . requestId }
55+ onPress = { ( ) => void props . onRespond ( props . approval . requestId , option . decision ) }
56+ >
57+ < Text
58+ className = { `text-sm ${
59+ option . decision === "accept"
60+ ? "font-t3-extrabold text-white"
61+ : option . decision === "decline"
62+ ? "font-t3-bold text-rose-700 dark:text-rose-300"
63+ : "font-t3-bold text-neutral-950 dark:text-neutral-50"
64+ } `}
65+ >
66+ { option . label }
67+ </ Text >
68+ </ Pressable >
69+ ) ) }
5670 </ View >
5771 </ View >
5872 ) ;
0 commit comments