import type { LeadActivityType, LeadSource, LeadStatus } from "@/lib/appwrite/schema";

export type { LeadStatus, LeadSource, LeadActivityType };

export type LeadRow = {
  id: string;
  name: string;
  contactName: string;
  email: string;
  phone: string;
  source: LeadSource;
  status: LeadStatus;
  estimatedValue: number | null;
  currency: string;
  notes: string;
  assigneeId: string;
  assigneeName: string;
  lastContactAt: string | null;
  nextFollowUpAt: string | null;
  calendarEventId: string | null;
  customerId: string | null;
  createdAt: string;
};

export type ActivityRow = {
  id: string;
  leadId: string;
  type: LeadActivityType;
  content: string;
  calendarEventId: string | null;
  occurredAt: string | null;
  createdAt: string;
  createdByName: string;
};

export type MemberOption = { id: string; name: string; email: string };

export const LEAD_STATUS_CONFIG: Record<
  LeadStatus,
  { label: string; color: string; bg: string; border: string }
> = {
  cold:      { label: "Soğuk",     color: "text-blue-600 dark:text-blue-400",   bg: "bg-blue-500/10",   border: "border-blue-500/30" },
  warm:      { label: "Ilık",      color: "text-orange-600 dark:text-orange-400", bg: "bg-orange-500/10", border: "border-orange-500/30" },
  hot:       { label: "Sıcak",     color: "text-red-600 dark:text-red-400",     bg: "bg-red-500/10",    border: "border-red-500/30" },
  converted: { label: "Kazanıldı", color: "text-green-600 dark:text-green-400", bg: "bg-green-500/10",  border: "border-green-500/30" },
  lost:      { label: "Kaybedildi",color: "text-muted-foreground",              bg: "bg-muted/40",      border: "border-border" },
};

export const LEAD_SOURCE_LABEL: Record<LeadSource, string> = {
  website:   "Website",
  social:    "Sosyal medya",
  referral:  "Referans",
  cold_call: "Soğuk arama",
  event:     "Fuar / Etkinlik",
  other:     "Diğer",
};

export const ACTIVITY_TYPE_CONFIG: Record<LeadActivityType, { label: string; icon: string }> = {
  note:          { label: "Not",            icon: "📝" },
  call:          { label: "Arama",          icon: "📞" },
  meeting:       { label: "Toplantı",       icon: "🤝" },
  email:         { label: "E-posta",        icon: "✉️" },
  status_change: { label: "Durum değişti",  icon: "🔄" },
};

export const COLUMNS: { key: LeadStatus; title: string }[] = [
  { key: "cold",      title: "Soğuk" },
  { key: "warm",      title: "Ilık" },
  { key: "hot",       title: "Sıcak" },
  { key: "converted", title: "Kazanıldı" },
  { key: "lost",      title: "Kaybedildi" },
];
