import React, { useState } from 'react'; import { View, TouchableOpacity } from 'react-native'; import { MyText, tw, BottomDialog, MyTextInput } from 'common-ui'; import { trpc } from '@/src/trpc-client'; import MaterialIcons from '@expo/vector-icons/MaterialIcons'; import { Alert } from 'react-native'; interface UserIncidentDialogProps { orderId: number; userId: number; open: boolean; onClose: () => void; onSuccess?: () => void; } export default function UserIncidentDialog({ orderId, userId, open, onClose, onSuccess }: UserIncidentDialogProps) { const [adminComment, setAdminComment] = useState(''); const [negativityScore, setNegativityScore] = useState(''); const addIncidentMutation = trpc.admin.user.addUserIncident.useMutation({ onSuccess: () => { Alert.alert('Success', 'Incident added successfully'); setAdminComment(''); setNegativityScore(''); onClose(); onSuccess?.(); }, onError: (error: any) => { Alert.alert('Error', error.message || 'Failed to add incident'); }, }); const handleAddIncident = () => { const score = negativityScore ? parseInt(negativityScore) : undefined; if (!adminComment.trim() && !negativityScore) { Alert.alert('Error', 'Please enter a comment or negativity score'); return; } addIncidentMutation.mutate({ userId, orderId, adminComment: adminComment || undefined, negativityScore: score, }); }; return ( Add User Incident Record an incident for this user. This will be visible in their profile. Higher negativity scores indicate more serious incidents (e.g., repeated cancellations, abusive behavior). Cancel {addIncidentMutation.isPending ? 'Adding...' : 'Add Incident'} ); }