import { useState, useRef } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faPhoneHangup } from '@fortawesome/pro-duotone-svg-icons'; import { Dialog, Modal, ModalOverlay } from '@/components/application/modals/modal'; import { FeaturedIcon } from '@/components/foundations/featured-icon/featured-icon'; import { TextArea } from '@/components/base/textarea/textarea'; import type { FC } from 'react'; import type { CallDisposition } from '@/types/entities'; import { cx } from '@/utils/cx'; const PhoneHangUpIcon: FC<{ className?: string }> = ({ className }) => ( ); const dispositionOptions: Array<{ value: CallDisposition; label: string; activeClass: string; defaultClass: string; }> = [ { value: 'APPOINTMENT_BOOKED', label: 'Appointment Booked', activeClass: 'bg-success-solid text-white border-transparent', defaultClass: 'bg-success-primary text-success-primary border-success', }, { value: 'FOLLOW_UP_SCHEDULED', label: 'Follow-up Needed', activeClass: 'bg-brand-solid text-white border-transparent', defaultClass: 'bg-brand-primary text-brand-secondary border-brand', }, { value: 'INFO_PROVIDED', label: 'Info Provided', activeClass: 'bg-utility-blue-light-600 text-white border-transparent', defaultClass: 'bg-utility-blue-light-50 text-utility-blue-light-700 border-utility-blue-light-200', }, { value: 'NO_ANSWER', label: 'No Answer', activeClass: 'bg-warning-solid text-white border-transparent', defaultClass: 'bg-warning-primary text-warning-primary border-warning', }, { value: 'WRONG_NUMBER', label: 'Wrong Number', activeClass: 'bg-secondary-solid text-white border-transparent', defaultClass: 'bg-secondary text-secondary border-secondary', }, { value: 'CALLBACK_REQUESTED', label: 'Not Interested', activeClass: 'bg-error-solid text-white border-transparent', defaultClass: 'bg-error-primary text-error-primary border-error', }, ]; type DispositionModalProps = { isOpen: boolean; callerName: string; callerDisconnected: boolean; defaultDisposition?: CallDisposition | null; onSubmit: (disposition: CallDisposition, notes: string) => void; onDismiss?: () => void; }; export const DispositionModal = ({ isOpen, callerName, callerDisconnected, defaultDisposition, onSubmit, onDismiss }: DispositionModalProps) => { const [selected, setSelected] = useState(null); const [notes, setNotes] = useState(''); const appliedDefaultRef = useRef(undefined); // Pre-select when modal opens with a suggestion if (isOpen && defaultDisposition && appliedDefaultRef.current !== defaultDisposition) { appliedDefaultRef.current = defaultDisposition; setSelected(defaultDisposition); } const handleSubmit = () => { if (selected === null) return; onSubmit(selected, notes); setSelected(null); setNotes(''); appliedDefaultRef.current = undefined; }; return ( { if (!open && onDismiss) onDismiss(); }}> {() => (
{/* Header */}

{callerDisconnected ? 'Call Disconnected' : 'End Call'}

{callerDisconnected ? `${callerName} disconnected. What was the outcome?` : `Select a reason to end the call with ${callerName}.` }

{/* Disposition options */}
{dispositionOptions.map((option) => { const isSelected = selected === option.value; return ( ); })}