feat(crm): Complete Admin Action Center & Reliability Overhaul
- Added ActionCenterWidget, DetailDrawer, AgentSelectionModal - Implemented global ErrorBoundary and Chatbot resilience - Updated documentation (README, Structure, Status, Overview) - Refined responsive design and modal portals
This commit is contained in:
@@ -30,6 +30,35 @@ TONE: Professional, efficient, and data-aware.
|
||||
`;
|
||||
|
||||
const getEmployeeContext = (user, meetings, properties) => {
|
||||
// --- ADMIN SPECIFIC CONTEXT ---
|
||||
if (user.role === 'ADMIN') {
|
||||
const unassignedCount = properties.filter(p => !p.assignedAgentId && p.canvassingStatus === 'Lead').length;
|
||||
// Last contact > 24h ago logic
|
||||
const hotLeadCount = properties.filter(p => p.canvassingStatus === 'Hot Lead' && (!p.lastContactDate || new Date(p.lastContactDate) < new Date(Date.now() - 86400000))).length;
|
||||
const rescheduleCount = meetings.filter(m => m.status === 'Cancelled' || m.status === 'Missed').length;
|
||||
const signatureCount = properties.filter(p => p.pendingSignature).length;
|
||||
const totalUrgent = unassignedCount + hotLeadCount + rescheduleCount + signatureCount;
|
||||
|
||||
return `
|
||||
ROLE: ADMIN (${user.name})
|
||||
|
||||
*** URGENT ACTION CENTER SUMMARY (${totalUrgent} Items) ***
|
||||
1. UNASSIGNED LEADS: ${unassignedCount}
|
||||
- Action: Assign agents to these leads immediately.
|
||||
2. HOT LEADS (Inactive > 24h): ${hotLeadCount}
|
||||
- Action: These high-value leads need a follow-up call.
|
||||
3. RESCHEDULE NEEDED: ${rescheduleCount}
|
||||
- Action: Re-book these cancelled/missed appointments.
|
||||
4. PENDING SIGNATURES: ${signatureCount}
|
||||
- Action: Send reminders to close these deals.
|
||||
|
||||
GENERAL DATA ACCESS:
|
||||
- Total Properties: ${properties.length}
|
||||
- Total Revenue (All Agents): $${meetings.filter(m => m.status === 'Converted').reduce((sum, m) => sum + (m.dealValue || 0), 0).toLocaleString()}
|
||||
`;
|
||||
}
|
||||
|
||||
// --- FIELD AGENT CONTEXT (Existing Logic) ---
|
||||
// 1. Agenda (Today + Upcoming)
|
||||
const today = new Date().toISOString().split('T')[0];
|
||||
const myMeetings = meetings
|
||||
@@ -248,6 +277,7 @@ const Chatbot = () => {
|
||||
const handleSend = async () => {
|
||||
if (!input.trim()) return;
|
||||
|
||||
const originalInput = input; // Backup input
|
||||
const newMessages = [...messages, { role: 'user', content: input }];
|
||||
setMessages(newMessages);
|
||||
setInput('');
|
||||
@@ -337,6 +367,8 @@ const Chatbot = () => {
|
||||
|
||||
} catch (error) {
|
||||
logger.error("Groq API Error", error);
|
||||
setInput(originalInput); // <--- RESTORE INPUT ON ERROR
|
||||
|
||||
let errorMsg = "Sorry, I'm having trouble connecting to the Groq server.";
|
||||
|
||||
if (error.message) {
|
||||
|
||||
Reference in New Issue
Block a user