import { formatCrmActivityLabel } from '@/features/crm/activity/types'; import type { ActivityTimelineItem } from '../../api/types'; import type { OpportunityFollowupRecord } from '@/features/crm/opportunities/api/types'; export interface OpportunityFollowupAdapterCandidate { source: 'opportunity_followup'; followup: OpportunityFollowupRecord; followupTypeLabel?: string | null; createdByName?: string | null; } export function adaptOpportunityFollowupCandidate( candidate: OpportunityFollowupAdapterCandidate ): ActivityTimelineItem { const typeLabel = candidate.followupTypeLabel ?? formatCrmActivityLabel(candidate.followup.followupType); return { id: candidate.followup.id, source: 'opportunity_followup', sourceLabel: 'Opportunity Follow-up', isLegacy: true, activityId: null, activityCode: null, primaryEntityType: 'opportunity', primaryEntityId: candidate.followup.opportunityId, primaryRecordLabel: null, activityType: 'follow_up', activityTypeLabel: typeLabel, subject: typeLabel, description: candidate.followup.outcome ?? candidate.followup.notes, status: 'completed', statusLabel: 'Completed', occurredAt: candidate.followup.followupDate, scheduledAt: candidate.followup.followupDate, dueAt: candidate.followup.nextFollowupDate, nextAction: candidate.followup.nextAction, ownerName: null, assignedToName: null, createdByName: candidate.createdByName ?? null }; }