Files
alla-allaos-fullstack/src/features/crm/activities/server/adapters/lead-followup.adapter.ts
phaichayon e96320a24d task-ep.1.2
2026-07-13 09:49:45 +07:00

42 lines
1.3 KiB
TypeScript

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
};
}