|
| 1 | +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@/components/ui/dialog"; |
| 2 | +import { Badge } from "@/components/ui/badge"; |
| 3 | +import { Mail, Building2, Phone } from "lucide-react"; |
| 4 | +import moment from "moment"; |
| 5 | + |
| 6 | +interface Props { |
| 7 | + lead: any | null; |
| 8 | + onClose: () => void; |
| 9 | + getStatusStyles: (status: string) => string; |
| 10 | +} |
| 11 | + |
| 12 | +export function ListLeadDetailsModal({ lead, onClose, getStatusStyles }: Props) { |
| 13 | + if (!lead) return null; |
| 14 | + |
| 15 | + const contacts = lead._allContacts || [{ |
| 16 | + id: lead.id, |
| 17 | + firstName: lead.firstName, |
| 18 | + lastName: lead.lastName, |
| 19 | + email: lead.email, |
| 20 | + phone: lead.phone, |
| 21 | + jobTitle: lead.jobTitle, |
| 22 | + contactId: lead.contactId, |
| 23 | + }]; |
| 24 | + |
| 25 | + const uniqueEmails = Array.from(new Set(contacts.map((c: any) => c.email).filter(Boolean))) as string[]; |
| 26 | + const uniquePhones = Array.from(new Set(contacts.map((c: any) => c.phone).filter(Boolean))) as string[]; |
| 27 | + |
| 28 | + return ( |
| 29 | + <Dialog open={!!lead} onOpenChange={(v) => !v && onClose()}> |
| 30 | + <DialogContent className="max-w-2xl p-0 overflow-hidden bg-zinc-950 border-zinc-800 shadow-2xl"> |
| 31 | + <div className="p-6 sm:p-8"> |
| 32 | + <DialogHeader className="mb-6"> |
| 33 | + <div className="flex items-center gap-4"> |
| 34 | + <div className="p-3.5 rounded-2xl bg-indigo-500/10 border border-indigo-500/20 text-indigo-400"> |
| 35 | + <Building2 className="w-6 h-6" /> |
| 36 | + </div> |
| 37 | + <div> |
| 38 | + <DialogTitle className="text-2xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-white to-zinc-400 tracking-tight"> |
| 39 | + {lead.company || lead.lastName || "Unknown Account"} |
| 40 | + </DialogTitle> |
| 41 | + <DialogDescription className="text-zinc-500 text-sm mt-1"> |
| 42 | + List Details & Discovered Intelligence |
| 43 | + </DialogDescription> |
| 44 | + </div> |
| 45 | + </div> |
| 46 | + </DialogHeader> |
| 47 | + |
| 48 | + <div className="grid grid-cols-1 md:grid-cols-2 gap-6"> |
| 49 | + <div className="space-y-6"> |
| 50 | + <div> |
| 51 | + <h4 className="text-[10px] font-bold text-zinc-500 uppercase tracking-widest mb-3 italic">Account Routing</h4> |
| 52 | + <div className="p-5 rounded-2xl border border-zinc-800/50 bg-zinc-900/50 space-y-4 hover:border-indigo-500/30 transition-colors"> |
| 53 | + <div className="flex items-start gap-3"> |
| 54 | + <Mail className="w-4 h-4 text-zinc-500 shrink-0 mt-0.5" /> |
| 55 | + <div className="flex flex-col gap-2 w-full min-w-0"> |
| 56 | + <div> |
| 57 | + <span className="text-xs font-medium text-zinc-400 block mb-1">Primary Email</span> |
| 58 | + <div className="text-sm font-semibold truncate text-zinc-200 bg-zinc-950 border border-zinc-800 px-3 py-1.5 rounded-lg inline-block"> |
| 59 | + {uniqueEmails[0] || "No primary email"} |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + |
| 63 | + {uniqueEmails.length > 1 && ( |
| 64 | + <div className="pt-2 border-t border-zinc-800/50"> |
| 65 | + <span className="text-xs font-medium text-zinc-400 block mb-2">Additional Intelligence</span> |
| 66 | + <div className="flex flex-col gap-1.5"> |
| 67 | + {uniqueEmails.slice(1).map((e, idx) => ( |
| 68 | + <Badge variant="secondary" key={idx} className="font-normal text-xs bg-indigo-500/10 text-indigo-300 hover:bg-indigo-500/20 border-indigo-500/20 justify-start px-2.5 py-1"> |
| 69 | + {e} |
| 70 | + </Badge> |
| 71 | + ))} |
| 72 | + </div> |
| 73 | + </div> |
| 74 | + )} |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + </div> |
| 79 | + |
| 80 | + <div> |
| 81 | + <h4 className="text-[10px] font-bold text-zinc-500 uppercase tracking-widest mb-3 italic">Lifecycle Status</h4> |
| 82 | + <div className="p-5 rounded-2xl border border-zinc-800/50 bg-zinc-900/50 space-y-3 hover:border-zinc-700 transition-colors"> |
| 83 | + {lead.status && ( |
| 84 | + <div className="flex justify-between items-center text-sm"> |
| 85 | + <span className="text-zinc-400">Pipeline Status</span> |
| 86 | + <Badge variant="outline" className={`font-mono text-[10px] uppercase tracking-wider border ${getStatusStyles(lead.status)}`}> |
| 87 | + {lead.status === 'CONVERTED' ? 'In CRM' : (lead.status || "New")} |
| 88 | + </Badge> |
| 89 | + </div> |
| 90 | + )} |
| 91 | + {uniquePhones.length > 0 && ( |
| 92 | + <div className="flex justify-between items-start text-sm pt-2 border-t border-zinc-800/50"> |
| 93 | + <div className="flex items-center gap-2 text-zinc-400"> |
| 94 | + <Phone className="w-3 h-3" /> |
| 95 | + <span>Phones</span> |
| 96 | + </div> |
| 97 | + <div className="flex flex-col text-right"> |
| 98 | + {uniquePhones.map((p, i) => ( |
| 99 | + <span key={i} className="font-medium text-zinc-300">{p}</span> |
| 100 | + ))} |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + )} |
| 104 | + </div> |
| 105 | + </div> |
| 106 | + </div> |
| 107 | + |
| 108 | + <div className="space-y-6"> |
| 109 | + <div> |
| 110 | + <h4 className="text-[10px] font-bold text-zinc-500 uppercase tracking-widest mb-3 italic">Decision Makers</h4> |
| 111 | + <div className="p-5 rounded-2xl border border-zinc-800/50 bg-zinc-900/50 space-y-3 hover:border-zinc-700 transition-colors"> |
| 112 | + {contacts && contacts.length > 0 ? ( |
| 113 | + <div className="space-y-3"> |
| 114 | + {contacts.map((c: any, i: number) => ( |
| 115 | + <div key={i} className="flex items-start gap-3 pt-3 border-t border-zinc-800/50 first:pt-0 first:border-0"> |
| 116 | + <div className="w-8 h-8 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center text-emerald-400 font-bold text-xs shrink-0 mt-0.5"> |
| 117 | + {c.firstName?.[0] || ""}{c.lastName?.[0] || ""} |
| 118 | + </div> |
| 119 | + <div className="flex flex-col min-w-0"> |
| 120 | + <span className="text-sm font-medium text-zinc-200"> |
| 121 | + {c.firstName} {c.lastName} |
| 122 | + </span> |
| 123 | + {c.jobTitle && ( |
| 124 | + <span className="text-xs text-zinc-500 truncate">{c.jobTitle}</span> |
| 125 | + )} |
| 126 | + <div className="flex items-center gap-2 mt-1"> |
| 127 | + {c.email && <span className="text-[10px] text-zinc-400 truncate border border-zinc-800/50 rounded px-1">{c.email}</span>} |
| 128 | + {c.contactId && <Badge variant="outline" className="text-[8px] h-4 py-0 px-1 border-indigo-500/20 text-indigo-400 bg-indigo-500/10">In CRM</Badge>} |
| 129 | + </div> |
| 130 | + </div> |
| 131 | + </div> |
| 132 | + ))} |
| 133 | + </div> |
| 134 | + ) : ( |
| 135 | + <div className="text-center py-4"> |
| 136 | + <p className="text-xs text-zinc-500 italic">No contacts registered.</p> |
| 137 | + </div> |
| 138 | + )} |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + |
| 142 | + <div> |
| 143 | + <h4 className="text-[10px] font-bold text-zinc-500 uppercase tracking-widest mb-3 italic">System Footprint</h4> |
| 144 | + <div className="p-5 rounded-2xl border border-zinc-800/50 bg-zinc-900/50 space-y-3 hover:border-zinc-700 transition-colors"> |
| 145 | + <div className="flex justify-between items-center text-sm"> |
| 146 | + <span className="text-zinc-400">Imported On</span> |
| 147 | + <span className="text-zinc-300 font-medium"> |
| 148 | + {lead.createdAt ? moment(lead.createdAt).format("MMM Do YYYY, h:mm a") : "Unknown"} |
| 149 | + </span> |
| 150 | + </div> |
| 151 | + {lead.accountId && ( |
| 152 | + <div className="flex justify-between items-center text-sm pt-2 border-t border-zinc-800/50"> |
| 153 | + <span className="text-zinc-400">Account ID</span> |
| 154 | + <span className="font-mono text-[10px] bg-zinc-950 px-2 py-1 rounded border border-zinc-800 text-zinc-500"> |
| 155 | + {lead.accountId} |
| 156 | + </span> |
| 157 | + </div> |
| 158 | + )} |
| 159 | + <div className="flex justify-between items-center text-sm pt-2 border-t border-zinc-800/50"> |
| 160 | + <span className="text-zinc-400">Lead Record ID</span> |
| 161 | + <span className="font-mono text-[10px] bg-zinc-950 px-2 py-1 rounded border border-zinc-800 text-zinc-500"> |
| 162 | + {lead.id.slice(0, 12)}... |
| 163 | + </span> |
| 164 | + </div> |
| 165 | + </div> |
| 166 | + </div> |
| 167 | + </div> |
| 168 | + </div> |
| 169 | + </div> |
| 170 | + </DialogContent> |
| 171 | + </Dialog> |
| 172 | + ); |
| 173 | +} |
0 commit comments