All files / src/lib crm-constants.ts

100% Statements 8/8
100% Branches 4/4
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39        1x                     1x 8x                 5x 5x 5x               4x 4x    
/**
 * Shared CRM constants used across pipeline, analytics, and lead detail views.
 */
 
export const LOSS_REASON_LABELS: Record<string, string> = {
	budget_constraints: "Budget Constraints",
	chose_competitor: "Chose Competitor",
	project_cancelled: "Project Cancelled",
	not_responding: "Not Responding",
	timeline_mismatch: "Timeline Mismatch",
	design_preferences: "Design Preferences",
	scope_change: "Scope Change",
	other: "Other",
};
 
export const LOSS_REASON_OPTIONS = Object.entries(LOSS_REASON_LABELS).map(
	([value, label]) => ({ value, label }),
);
 
/**
 * Build a WhatsApp URL for a phone number.
 * Indian numbers (10 digits) get the 91 country code prepended.
 * Other numbers are used as-is (assumed to already include country code).
 */
export function whatsappUrl(phone: string): string {
	const digits = phone.replace(/\D/g, "");
	const withCountry = digits.length === 10 ? `91${digits}` : digits;
	return `https://wa.me/${withCountry}`;
}
 
/**
 * Build a tel: URI for a phone number.
 * Indian numbers (10 digits) get +91 prepended.
 */
export function telUrl(phone: string): string {
	const digits = phone.replace(/\D/g, "");
	return digits.length === 10 ? `tel:+91${digits}` : `tel:+${digits}`;
}