import { useState } from 'react' import { Bot, Mail, MessageSquare, Phone, StickyNote, Users } from 'lucide-react' import { Modal, Panel } from '../../components/ui' import type { RActivity } from '../../lib/types' import { useActivities, useLogActivity } from './activityQueries' const inputCls = 'w-full rounded-lg border border-line/70 bg-navy-900 px-3 py-2 text-sm text-ink outline-none focus:border-recruit' const KINDS = ['call', 'email', 'inmail', 'text', 'meeting', 'note'] as const const OUTCOMES = ['logged', 'connected', 'no_answer', 'left_message', 'replied', 'bounced', 'declined'] as const // Only these two mean a person was actually reached, mirrored from the service. A hundred dials with two // conversations is a different day from a hundred conversations. const CONNECTS = new Set(['connected', 'replied']) function kindIcon(kind: string) { switch (kind) { case 'call': return case 'email': case 'inmail': return case 'text': return case 'meeting': return case 'submission': case 'screen': return default: return } } export function ActivityFeed({ candidateId, requisitionId, applicationId, title = 'Activity', }: { candidateId?: string requisitionId?: string applicationId?: string title?: string }) { const [showCaptured, setShowCaptured] = useState(false) const scope = { candidate_id: candidateId, requisition_id: requisitionId, application_id: applicationId, include_captured: showCaptured, } const q = useActivities(scope) const log = useLogActivity() const [open, setOpen] = useState(false) const [kind, setKind] = useState('call') const [outcome, setOutcome] = useState('logged') const [note, setNote] = useState('') const [when, setWhen] = useState('') const rows = q.data?.activities ?? [] const submit = () => { log.mutate( { kind, outcome, body: note, candidate_id: candidateId ?? '', requisition_id: requisitionId ?? '', application_id: applicationId ?? '', // Backdating is allowed and forward dating is refused by the server, which is what keeps // today's numbers honest. occurred_at: when ? new Date(when).toISOString() : '', }, { onSuccess: () => { setNote('') setWhen('') setOutcome('logged') setOpen(false) }, }, ) } return (
{/* Captured rows are opt in. A recruiter's log means what they did; mixing in everything the platform recorded on their behalf would drown it. */}
{q.isError ? (

Could not load activity. {(q.error as Error)?.message}

) : rows.length === 0 ? (

Nothing logged yet. Calls, emails and notes recorded here are what the recruiting metrics are built from.

) : (
    {rows.map((a: RActivity) => (
  • {kindIcon(a.kind)}

    {a.kind} {a.outcome.replace(/_/g, ' ')} {a.auto_captured && ( platform )}

    {a.body &&

    {a.body}

    }

    {new Date(a.occurred_at).toLocaleString()} {a.actor_name ? ` · ${a.actor_name}` : ''} {a.candidate_name && !candidateId ? ` · ${a.candidate_name}` : ''}

  • ))}
)} setOpen(false)} title="Log an activity">