import type { ApprovalRequestId, ProviderApprovalDecision, ProviderApprovalOption, } from "@t3tools/contracts"; import { Pressable, View } from "react-native"; import { AppText as Text } from "../../components/AppText"; import type { PendingApproval } from "../../lib/threadActivity"; export interface PendingApprovalCardProps { readonly approval: PendingApproval; readonly respondingApprovalId: ApprovalRequestId | null; readonly onRespond: ( requestId: ApprovalRequestId, decision: ProviderApprovalDecision, ) => Promise; } const DEFAULT_APPROVAL_OPTIONS: ReadonlyArray = [ { decision: "accept", label: "Allow once" }, { decision: "acceptForSession", label: "Allow session" }, { decision: "decline", label: "Decline" }, ]; export function PendingApprovalCard(props: PendingApprovalCardProps) { const options: ReadonlyArray = props.approval.options ?? DEFAULT_APPROVAL_OPTIONS; const warning = options.find((option) => option.warning)?.warning; // Opaque for the same reason as PendingUserInputCard: nothing blurs the feed // behind this card, so a translucent surface bleeds messages through it. return ( Approval needed {props.approval.appName ?? props.approval.requestKind} {props.approval.detail ? ( {props.approval.detail} ) : null} {warning ? ( {warning} ) : null} {options.map((option) => ( void props.onRespond(props.approval.requestId, option.decision)} > {option.label} ))} ); }