import React, { useState } from 'react'
import { p as P, BottomDialog, pInput as PInput } from 'web-components'
import { trpc } from '@/lib/trpc-client'
import { TriangleAlert, Info, Plus, Calendar, User, ShoppingCart, CircleCheck } from 'lucide-react'
import dayjs from 'dayjs'
function UserIncidentDialog({
userId,
orderId,
open,
onClose,
onSuccess
}: {
userId: number
orderId: number | null
open: boolean
onClose: () => void
onSuccess?: () => void
}) {
const [adminComment, setAdminComment] = useState('')
const [negativityScore, setNegativityScore] = useState('')
const addIncidentMutation = trpc.admin.user.addUserIncident.useMutation({
onSuccess: () => {
window.alert('Success: Incident added successfully')
setAdminComment('')
setNegativityScore('')
onClose()
onSuccess?.()
},
onError: (error: any) => {
window.alert(`Error: ${error.message || 'Failed to add incident'}`)
},
})
const handleAddIncident = () => {
const score = negativityScore ? parseInt(negativityScore) : undefined
if (!adminComment.trim() && !negativityScore) {
window.alert('Error: Please enter a comment or negativity score')
return
}
addIncidentMutation.mutate({
userId,
orderId: orderId || undefined,
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).
User Incidents
{dayjs(incident.dateAdded).format('MMM DD, YYYY • h:mm A')}
Score: {incident.negativityScore}
{incident.adminComment}
Added by {incident.addedBy}
{incident.orderId && ( <>Order #{incident.orderId}
> )}No incidents recorded for this user