import { formatCrmActivityLabel } from '@/features/crm/activity/types'; import type { LeadFollowupSummary } from '@/features/crm/leads/types'; import type { ActivityTimelineItem } from '../../api/types'; export interface LeadFollowupAdapterCandidate { source: 'lead_followup'; followup: LeadFollowupSummary; } export function adaptLeadFollowupCandidate( candidate: LeadFollowupAdapterCandidate ): ActivityTimelineItem { const statusLabel = candidate.followup.followupStatusLabel ?? formatCrmActivityLabel(candidate.followup.followupStatus); return { id: candidate.followup.id, source: 'lead_followup', sourceLabel: 'Lead Follow-up', isLegacy: true, activityId: null, activityCode: null, primaryEntityType: 'lead', primaryEntityId: candidate.followup.leadId, primaryRecordLabel: null, activityType: 'follow_up', activityTypeLabel: 'Follow Up', subject: candidate.followup.note?.trim() || 'Lead follow-up', description: candidate.followup.note, status: candidate.followup.followupStatus, statusLabel, occurredAt: candidate.followup.followupDate, scheduledAt: candidate.followup.followupDate, dueAt: candidate.followup.nextFollowupDate, nextAction: null, ownerName: null, assignedToName: null, createdByName: candidate.followup.createdByName }; }