import type { TicketNote } from '@/api/psaContext'

interface Props {
  notes: TicketNote[]
}

export function TicketNotesFeed({ notes }: Props) {
  if (notes.length === 0) {
    return <p className="text-xs text-muted-foreground px-4 py-3">No notes yet.</p>
  }

  return (
    <div className="divide-y divide-default">
      {notes.map((note, i) => (
        <div key={i} className="px-4 py-3 space-y-1">
          <div className="flex items-center justify-between text-xs text-muted-foreground">
            <span>{note.member ?? 'Unknown'}</span>
            <span>{new Date(note.date_created).toLocaleDateString()}</span>
          </div>
          {note.internal_analysis_flag && (
            <span className="text-[10px] uppercase tracking-wider text-warning">Internal</span>
          )}
          <p className="text-sm text-primary whitespace-pre-wrap">{note.text}</p>
        </div>
      ))}
    </div>
  )
}
