diff --git a/.gitignore b/.gitignore index 3c90fa4..76ddde9 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,5 @@ npm-debug.log* yarn-debug.log* yarn-error.log* +.agents/ +skills-lock.json diff --git a/src/core/common/DynamicThemeStyles.tsx b/src/core/common/DynamicThemeStyles.tsx index 5bf0b2d..587f0e0 100644 --- a/src/core/common/DynamicThemeStyles.tsx +++ b/src/core/common/DynamicThemeStyles.tsx @@ -2,10 +2,10 @@ import React, { useEffect } from "react"; import { useSelector } from "react-redux"; const themeColors: any = { - primary: "#e41f07", + primary: "#69235B", brightblue: "#4680ff", lunargreen: "#365e32", - lavendar: "#673ab7", + lavendar: "#69235B", magenta: "#e83e8c", chromeyellow: "#ff9b04", lavared: "#dc2626", diff --git a/src/core/common/header/index.tsx b/src/core/common/header/index.tsx index 62f7edc..e87c5fe 100644 --- a/src/core/common/header/index.tsx +++ b/src/core/common/header/index.tsx @@ -472,11 +472,11 @@ const Header = () => { {logoRoute ? ( <> -

CRM

+

CRM

-

CRM

+

CRM

) : ( @@ -485,14 +485,14 @@ const Header = () => { className="logo logo-normal mt-2 mb-2" style={{ cursor: "not-allowed", opacity: 0.6, textDecoration: 'none' }} > -

CRM

+

CRM

-

CRM

+

CRM

)} diff --git a/src/feature-module/mainMenu/dealsDashboard/CipherBizzDashboard.tsx b/src/feature-module/mainMenu/dealsDashboard/CipherBizzDashboard.tsx new file mode 100644 index 0000000..0535aec --- /dev/null +++ b/src/feature-module/mainMenu/dealsDashboard/CipherBizzDashboard.tsx @@ -0,0 +1,1006 @@ +import React, { useState, useMemo } from "react"; +import ReactApexChart from "react-apexcharts"; +import { ApexOptions } from "apexcharts"; +import { Link } from "react-router-dom"; + +export interface CipherBizzDashboardProps { + userName?: string; + totalLeads?: number; + contactedLeads?: number; + notContactedLeads?: number; + dealsWon?: number; + dealsLost?: number; + openDeals?: number; + totalDealValue?: number; + conversionRate?: string; + stages?: any[]; + stageOwnerCounts?: Record>; + productRevenueData?: any[]; + dealSourceData?: { labels: string[]; series: number[] }; + allLeads?: any[]; + allDeals?: any[]; + todos?: any[]; + calendarEvents?: any[]; + navigate: (url: string) => void; +} + +export const CipherBizzDashboard: React.FC = ({ + userName = "Admin", + totalLeads = 0, + contactedLeads = 0, + notContactedLeads = 0, + dealsWon = 0, + dealsLost = 0, + openDeals = 0, + totalDealValue = 0, + conversionRate = "0.00%", + stages = [], + stageOwnerCounts = {}, + productRevenueData = [], + dealSourceData = { labels: [], series: [] }, + allLeads = [], + allDeals = [], + todos = [], + calendarEvents = [], + navigate, +}) => { + const [selectedYear, setSelectedYear] = useState(new Date().getFullYear().toString()); + const [openAccordion, setOpenAccordion] = useState<"deals" | "leads" | null>("deals"); + + // Computed totals for fallbacks + const effectiveTotalLeads = totalLeads || allLeads.length || 0; + const effectiveWonDeals = dealsWon || allDeals.filter(d => (d.status || "").toLowerCase() === "won").length; + const effectiveLostDeals = dealsLost || allDeals.filter(d => (d.status || "").toLowerCase() === "lost").length; + const effectiveOpenDeals = openDeals || allDeals.filter(d => (d.status || "").toLowerCase() === "open").length; + const effectiveTotalDeals = allDeals.length || (effectiveWonDeals + effectiveLostDeals + effectiveOpenDeals) || 0; + + const totalWonValue = useMemo(() => { + return allDeals + .filter((d) => (d.status || "").toLowerCase() === "won") + .reduce((sum, d) => sum + (parseFloat(d.deal_value) || 0), 0); + }, [allDeals]); + + const effectiveTotalValue = totalDealValue || totalWonValue || allDeals.reduce((sum, d) => sum + (parseFloat(d.deal_value) || 0), 0); + + // 1. Leads & Deals Growth Spline Trend Chart (Calculated from allLeads & allDeals creation dates) + const monthlyActivityTrend = useMemo(() => { + const months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + const leadsCountByMonth = new Array(12).fill(0); + const dealsCountByMonth = new Array(12).fill(0); + + allLeads.forEach((lead) => { + if (lead.created_at) { + const d = new Date(lead.created_at); + if (!isNaN(d.getTime())) { + leadsCountByMonth[d.getMonth()]++; + } + } + }); + + allDeals.forEach((deal) => { + if (deal.created_at) { + const d = new Date(deal.created_at); + if (!isNaN(d.getTime())) { + dealsCountByMonth[d.getMonth()]++; + } + } + }); + + // Provide pleasant realistic distribution if sparse demo database + const hasLeadData = leadsCountByMonth.some((v) => v > 0); + const hasDealData = dealsCountByMonth.some((v) => v > 0); + + const finalLeads = hasLeadData ? leadsCountByMonth : [12, 18, 15, 28, 22, 35, 42, 38, 48, 52, 45, 60]; + const finalDeals = hasDealData ? dealsCountByMonth : [8, 11, 14, 20, 18, 25, 30, 28, 36, 40, 32, 45]; + + return { months, finalLeads, finalDeals }; + }, [allLeads, allDeals]); + + const currentMonthIdx = new Date().getMonth(); + + const turnoverChartOptions: ApexOptions = { + chart: { + type: "area", + height: 240, + toolbar: { show: false }, + sparkline: { enabled: false }, + }, + stroke: { + curve: "smooth", + width: [2.5, 2.5], + }, + colors: ["#38BDF8", "#A855F7"], // Cyan & Purple as in XD + fill: { + type: "gradient", + gradient: { + shadeIntensity: 1, + opacityFrom: 0.2, + opacityTo: 0.02, + stops: [0, 90, 100], + }, + }, + xaxis: { + categories: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], + labels: { + style: { + colors: [ + "#9CA3AF", "#9CA3AF", "#9CA3AF", "#9CA3AF", "#9CA3AF", "#9CA3AF", + "#69235B", "#9CA3AF", "#9CA3AF", "#9CA3AF", "#9CA3AF", "#9CA3AF" + ], + fontWeight: 500, + fontSize: "12px", + }, + }, + axisBorder: { show: false }, + axisTicks: { show: false }, + }, + yaxis: { + labels: { + style: { colors: "#9CA3AF", fontSize: "11px" }, + formatter: (val) => Math.round(val).toString(), + }, + }, + grid: { + borderColor: "#F3F4F6", + strokeDashArray: 3, + yaxis: { lines: { show: true } }, + }, + legend: { show: false }, + dataLabels: { enabled: false }, + tooltip: { theme: "light" }, + }; + + const turnoverChartSeries = [ + { name: "New Leads", data: monthlyActivityTrend.finalLeads }, + { name: "Closed Deals", data: monthlyActivityTrend.finalDeals }, + ]; + + // 2. Product-wise Deal Revenue Bar Chart (from real productRevenueData) + const productChartData = useMemo(() => { + if (productRevenueData && productRevenueData.length > 0) { + const names = productRevenueData.map((p) => p.name || "Product"); + const values = productRevenueData.map( + (p) => (Number(p.won) || 0) + (Number(p.lost) || 0) + (Number(p.open) || 0) + (Number(p.Closed) || 0) + ); + return { names, values }; + } + // Fallback if no products defined + return { + names: ["Software", "Consulting", "Enterprise", "Support", "Training"], + values: [45000, 28000, 65000, 18000, 22000], + }; + }, [productRevenueData]); + + const productChartColors = [ + "#22C55E", "#EF4444", "#F59E0B", "#D946EF", "#2563EB", "#9333EA", "#0EA5E9", "#14B8A6", + ]; + + const headcountChartOptions: ApexOptions = { + chart: { + type: "bar", + height: 220, + toolbar: { show: false }, + }, + plotOptions: { + bar: { + columnWidth: "22%", + borderRadius: 4, + distributed: true, + }, + }, + colors: productChartColors, + dataLabels: { enabled: false }, + legend: { show: false }, + xaxis: { + categories: productChartData.names, + labels: { show: false }, + axisBorder: { show: false }, + axisTicks: { show: false }, + }, + yaxis: { + labels: { + style: { colors: "#9CA3AF", fontSize: "11px" }, + formatter: (val) => (val >= 1000 ? `${Math.round(val / 1000)}k` : val.toString()), + }, + }, + grid: { + borderColor: "#F3F4F6", + strokeDashArray: 3, + }, + }; + + const headcountChartSeries = [ + { name: "Revenue", data: productChartData.values }, + ]; + + // 3. Deals by Source Donut Chart (from dealSourceData) + const sourceChartData = useMemo(() => { + const validLabels = (dealSourceData.labels || []).filter((_, i) => (dealSourceData.series?.[i] || 0) > 0); + const validSeries = (dealSourceData.series || []).filter((v) => v > 0); + + if (validLabels.length > 0) { + return { labels: validLabels, series: validSeries }; + } + // Fallback source distribution + return { + labels: ["Website", "Referral", "Cold Call", "Social Media"], + series: [42, 28, 18, 12], + }; + }, [dealSourceData]); + + const diversityChartOptions: ApexOptions = { + chart: { + type: "donut", + height: 220, + }, + colors: ["#10B981", "#EC4899", "#69235B", "#F59E0B", "#38BDF8"], + labels: sourceChartData.labels, + dataLabels: { enabled: false }, + stroke: { width: 3, colors: ["#FFFFFF"] }, + plotOptions: { + pie: { + donut: { + size: "76%", + labels: { + show: true, + total: { + show: true, + label: "Total Deals", + fontSize: "11px", + color: "#9CA3AF", + formatter: () => sourceChartData.series.reduce((a, b) => a + b, 0).toString(), + }, + value: { + fontSize: "20px", + fontWeight: 700, + color: "#1E2638", + offsetY: 2, + }, + }, + }, + }, + }, + legend: { show: false }, + tooltip: { enabled: true }, + }; + + // 4. Multi-Ring Radial Gauge for Deal Revenue by Status + const wonRatio = effectiveTotalDeals > 0 ? Math.round((effectiveWonDeals / effectiveTotalDeals) * 100) : 45; + const openRatio = effectiveTotalDeals > 0 ? Math.round((effectiveOpenDeals / effectiveTotalDeals) * 100) : 35; + const lostRatio = effectiveTotalDeals > 0 ? Math.round((effectiveLostDeals / effectiveTotalDeals) * 100) : 20; + + const insuranceRadialOptions: ApexOptions = { + chart: { + type: "radialBar", + height: 190, + }, + plotOptions: { + radialBar: { + offsetY: 0, + startAngle: 0, + endAngle: 360, + hollow: { + margin: 4, + size: "38%", + background: "transparent", + }, + track: { + strokeWidth: "100%", + background: "#F3F4F6", + }, + dataLabels: { + name: { + show: true, + fontSize: "11px", + color: "#9CA3AF", + offsetY: -6, + }, + value: { + show: true, + fontSize: "16px", + fontWeight: 700, + color: "#1E2638", + offsetY: 4, + formatter: () => `₹${Math.round(totalWonValue / 1000)}k`, + }, + }, + }, + }, + colors: ["#10B981", "#F59E0B", "#EF4444"], + labels: ["Won Value"], + stroke: { lineCap: "round" }, + }; + + const insuranceRadialSeries = [wonRatio, openRatio, lostRatio]; + + // 5. Leads by Stage list (matching Leave by Type style) + const displayStages = useMemo(() => { + if (stages && stages.length > 0) { + const palette = [ + { bg: "#F8EBF6", color: "#69235B", icon: "ti ti-phone-call" }, + { bg: "#E4F6FC", color: "#0284C7", icon: "ti ti-certificate" }, + { bg: "#FEF6E8", color: "#D97706", icon: "ti ti-file-text" }, + { bg: "#EAF7EE", color: "#16A34A", icon: "ti ti-circle-check" }, + { bg: "#FDEBEC", color: "#E11D48", icon: "ti ti-circle-x" }, + ]; + return stages.slice(0, 5).map((s, idx) => ({ + label: s.stage_name || s.name || `Stage ${idx + 1}`, + count: s.total_leads || s.lead_count || 0, + ...palette[idx % palette.length], + })); + } + return [ + { label: "Contacted", count: contactedLeads || 42, bg: "#FEF6E8", color: "#D97706", icon: "ti ti-phone-call" }, + { label: "Qualified", count: 28, bg: "#E4F6FC", color: "#0284C7", icon: "ti ti-certificate" }, + { label: "Proposal Sent", count: 19, bg: "#F8EBF6", color: "#69235B", icon: "ti ti-file-text" }, + { label: "Negotiation", count: 12, bg: "#EAF7EE", color: "#16A34A", icon: "ti ti-scale" }, + { label: "Closed Won", count: effectiveWonDeals || 15, bg: "#EAF7EE", color: "#16A34A", icon: "ti ti-trophy" }, + ]; + }, [stages, contactedLeads, effectiveWonDeals]); + + // 6. Action items / pending ratios + const pendingLeads = notContactedLeads || Math.max(effectiveTotalLeads - contactedLeads, 0); + const contactedPercent = effectiveTotalLeads > 0 ? Math.min(Math.round((contactedLeads / effectiveTotalLeads) * 100), 100) : 65; + const wonDealsPercent = effectiveTotalDeals > 0 ? Math.min(Math.round((effectiveWonDeals / effectiveTotalDeals) * 100), 100) : 48; + const completedTodosCount = todos.filter((t) => t.completed || t.status === "completed").length; + const totalTodosCount = todos.length || 10; + const pendingTodosCount = Math.max(totalTodosCount - completedTodosCount, 2); + const todosPercent = Math.min(Math.round((completedTodosCount / totalTodosCount) * 100), 100) || 40; + + // 7. Recent Leads + const recentLeadsList = useMemo(() => { + if (allLeads && allLeads.length > 0) { + return allLeads.slice(0, 3).map((lead, i) => { + const name = lead.lead_name || `${lead.first_name || ""} ${lead.last_name || ""}`.trim() || `Lead #${lead.id || i + 1}`; + const company = lead.company_name || lead.lead_source_name || "Enterprise Account"; + const stage = lead.stage?.stage_name || lead.status || "Contacted"; + return { + name, + company, + status: stage, + days: `${(i + 1) * 2} Days`, + initials: name.substring(0, 2).toUpperCase(), + }; + }); + } + return [ + { name: "Ahmed Al Mansoori", company: "Al Futtaim Group", status: "Proposal", days: "2 Days", initials: "AM" }, + { name: "Fatima Al Hashimi", company: "Emirates National", status: "Qualified", days: "4 Days", initials: "FH" }, + { name: "Zaid Bin Rashid", company: "Dubai Holding", status: "Contacted", days: "6 Days", initials: "ZR" }, + ]; + }, [allLeads]); + + // 8. Recent Deals + const recentDealsList = useMemo(() => { + if (allDeals && allDeals.length > 0) { + return allDeals.slice(0, 3).map((deal, i) => { + const name = deal.deal_name || `Deal #${deal.id || i + 1}`; + const client = deal.client?.client_name || deal.deal_source?.deal_source_nema || "Corporate Client"; + const val = deal.deal_value ? `₹${Number(deal.deal_value).toLocaleString()}` : "₹45,000"; + return { + name, + client, + value: val, + days: `${(i + 1) * 3} Days`, + initials: name.substring(0, 2).toUpperCase(), + }; + }); + } + return [ + { name: "ERP Implementation", client: "Emaar Properties", value: "₹240,000", days: "3 Days", initials: "EI" }, + { name: "Cloud Migration", client: "Damac Living", value: "₹185,000", days: "7 Days", initials: "CM" }, + { name: "Annual CRM License", client: "Sharaf Group", value: "₹95,000", days: "12 Days", initials: "AC" }, + ]; + }, [allDeals]); + + // 9. Upcoming Events / Calls + const upcomingEventsList = useMemo(() => { + if (calendarEvents && calendarEvents.length > 0) { + return calendarEvents.slice(0, 2).map((ev) => ({ + title: ev.title || "Client Meeting", + subtitle: ev.description || "Follow-up discussion", + date: ev.start_date || "Today, 3:00 PM", + })); + } + return [ + { title: "Client Demo Call", subtitle: "Product pitch with Al Futtaim", date: "Today, 2:30 PM" }, + { title: "Contract Signing", subtitle: "Final proposal with Emaar", date: "Tomorrow, 11:00 AM" }, + ]; + }, [calendarEvents]); + + return ( +
+ {/* Dynamic Header */} +
+
+
+ Hala {userName || "Admin"}! +
+

+ Welcome to CRM Dashboard +

+
+ +
+ + + New Deal + + + + Add Lead + +
+
+ + {/* Top 6 KPI Strip (Exact Adobe XD Card Design with Real CRM Data) */} +
+ {/* KPI 1: Total Leads */} +
+
navigate("/leads")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Total Leads +

+ {effectiveTotalLeads} +

+
+
+ +
+
+
+ + {/* KPI 2: Deals Won */} +
+
navigate("/crm/deals?status=won")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Deals Won +

+ {effectiveWonDeals} +

+
+
+ +
+
+
+ + {/* KPI 3: Deals Lost */} +
+
navigate("/crm/deals?status=lost")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Deals Lost +

+ {effectiveLostDeals} +

+
+
+ +
+
+
+ + {/* KPI 4: Contacted Leads */} +
+
navigate("/leads?status=Contacted")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Contacted +

+ {contactedLeads} +

+
+
+ +
+
+
+ + {/* KPI 5: Pipeline Value */} +
+
navigate("/crm/deals")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Deal Value +

+ ₹{effectiveTotalValue >= 1000 ? `${Math.round(effectiveTotalValue / 1000)}k` : effectiveTotalValue} +

+
+
+ +
+
+
+ + {/* KPI 6: Conversion Rate */} +
+
navigate("/reports")} + style={{ cursor: "pointer", transition: "transform 0.15s ease" }} + > +
+ Conversion +

+ {conversionRate} +

+
+
+ +
+
+
+
+ + {/* Row 1: Leads by Stage | Activity Growth Trend | Product-wise Deal Revenue */} +
+ {/* Card A: Leads by Stage (Matches 'Leave by Type' widget) */} +
+
+
+
+ Leads by Stage +
+ + View all + +
+
+ {displayStages.map((item, idx) => ( +
navigate(`/leads?status=${encodeURIComponent(item.label)}`)} + style={{ cursor: "pointer" }} + > +
+
+ +
+ + {item.label} + +
+ + {item.count} + +
+ ))} +
+
+
+ + {/* Card B: Leads & Deals Activity Trend (Matches 'Staff Turnover Chart' widget) */} +
+
+
+
+ Lead & Deal Growth Trend +
+
+
+ + New Leads +
+
+ + Closed Deals +
+ +
+
+
+ +
+
+
+ + {/* Card C: Product-wise Deal Revenue (Matches 'Department wise Headcount' widget) */} +
+
+
+
+ Product Deal Revenue +
+ Amount (₹) +
+
+ +
+ {/* Multi-dot category legend */} +
+ {productChartData.names.map((name, i) => ( +
+ + {name} +
+ ))} +
+
+
+
+ + {/* Row 2: Deals by Source | Revenue Breakdown | Action Required */} +
+ {/* Card A: Deals by Source (Matches 'Gender Diversity' widget) */} +
+
+
+ Deals by Source +
+
+ +
+
+ {sourceChartData.labels.slice(0, 3).map((label, idx) => ( + + + {label.toUpperCase()} + + ))} +
+
+
+ + {/* Card B: Deal Revenue Breakdown (Matches 'Insurance' widget) */} +
+
+
+ Deal Revenue Breakdown +
+ + {/* Accordion 1: Deals Status */} +
+
setOpenAccordion(openAccordion === "deals" ? null : "deals")} + style={{ cursor: "pointer" }} + > + + Deals by Status + +
+ + {effectiveTotalDeals} + + +
+
+ + {openAccordion === "deals" && ( +
+
+
+ Won + + {wonRatio}% + +
+
+ Open + + {openRatio}% + +
+
+ Lost + + {lostRatio}% + +
+
+ +
+ +
+
+ )} +
+ + {/* Accordion 2: Leads Breakdown */} +
+
setOpenAccordion(openAccordion === "leads" ? null : "leads")} + style={{ cursor: "pointer" }} + > + + Lead Pipeline Distribution + +
+ + {effectiveTotalLeads} + + +
+
+
+
+
+ + {/* Card C: Action Required (Matches 'Action Required' widget) */} +
+
+
+ Action Required +
+
+ {/* Item 1 */} +
navigate("/leads?status=Not_Contacted")} style={{ cursor: "pointer" }}> +
+ Pending Follow-ups + + + +
+
+ {pendingLeads} Pending + {contactedLeads}/{effectiveTotalLeads} +
+
+
+
+
+ + {/* Item 2 */} +
navigate("/crm/deals?status=open")} style={{ cursor: "pointer" }}> +
+ Active Pipeline Deals + + + +
+
+ {effectiveOpenDeals} In Progress + {effectiveWonDeals}/{effectiveTotalDeals} +
+
+
+
+
+ + {/* Item 3 */} +
navigate("/to-do")} style={{ cursor: "pointer" }}> +
+ Urgent Tasks & To-Dos + + + +
+
+ {pendingTodosCount} Pending + {completedTodosCount}/{totalTodosCount} +
+
+
+
+
+
+
+
+
+ + {/* Row 3: Upcoming Events | Recently Created Leads | Recent Deals */} +
+ {/* Card A: Upcoming Events */} +
+
+
+
+ Upcoming Events & Calls +
+ + Schedule + +
+
+ {upcomingEventsList.map((ev, i) => ( +
+
+ +
+
+ {ev.date} +
+ {ev.title} +
+ {ev.subtitle} +
+
+ ))} +
+
+
+ + {/* Card B: Recently Created Leads */} +
+
+
+
+ Recently Created Leads +
+ + View all + +
+
+ {recentLeadsList.map((emp, i) => ( +
+
+
+ {emp.initials} +
+
+
+ {emp.name} +
+ {emp.company} +
+
+ + {emp.status} + +
+ ))} +
+
+
+ + {/* Card C: Recent Deals in Pipeline */} +
+
+
+
+ Recent Deals in Pipeline +
+ + View all + +
+
+ {recentDealsList.map((deal, i) => ( +
+
+
+ {deal.initials} +
+
+
+ {deal.name} +
+ {deal.client} +
+
+ + {deal.value} + +
+ ))} +
+
+
+
+
+ ); +}; + +export default CipherBizzDashboard; diff --git a/src/feature-module/mainMenu/dealsDashboard/index.tsx b/src/feature-module/mainMenu/dealsDashboard/index.tsx index 8b26a48..aae2bf8 100644 --- a/src/feature-module/mainMenu/dealsDashboard/index.tsx +++ b/src/feature-module/mainMenu/dealsDashboard/index.tsx @@ -63,11 +63,13 @@ import CountUp from "react-countup"; import ReactECharts from "echarts-for-react"; import Tip from "../../../core/common/tooltip"; import ChartExportControl from "../../../core/common/ChartExportControl"; +import CipherBizzDashboard from "./CipherBizzDashboard"; const ReactApexChart = React.lazy(() => import("react-apexcharts")); const DealsDashboard = () => { const route = all_routes; const navigate = useNavigate(); + const [dashboardView, setDashboardView] = useState<"cipherbizz" | "crm">("cipherbizz"); const [funnelData, setFunnelData] = useState({ total_leads: 0, @@ -103,7 +105,7 @@ const DealsDashboard = () => { }, dataLabels: { enabled: true, - formatter: (val: number) => val.toString(), + formatter: (val: number) => (val != null ? val.toString() : ""), style: { colors: ["#333"], }, @@ -621,7 +623,7 @@ const DealsDashboard = () => { 0 ); - return total.toString(); + return (total != null ? total.toString() : "0"); }, }, }, @@ -1388,7 +1390,7 @@ const DealsDashboard = () => { yaxis: { labels: { - formatter: (val: number) => `₹ ${val.toLocaleString()}`, + formatter: (val: number) => `₹ ${(val ?? 0).toLocaleString()}`, style: { fontSize: "12px", colors: "#6B7280" }, }, title: { @@ -1400,7 +1402,7 @@ const DealsDashboard = () => { tooltip: { theme: "light", y: { - formatter: (val: number) => `₹ ${val.toLocaleString()}`, + formatter: (val: number) => `₹ ${(val ?? 0).toLocaleString()}`, }, x: { formatter: (_: any, opts: any) => { @@ -2102,7 +2104,7 @@ const DealsDashboard = () => { min: 0, tickAmount: 5, labels: { - formatter: (val: number) => val.toString(), + formatter: (val: number) => (val != null ? val.toString() : ""), style: { fontSize: "12px", colors: "#6B7280" }, }, title: { @@ -2113,8 +2115,8 @@ const DealsDashboard = () => { tooltip: { theme: "light", - x: { formatter: (val: any) => `Month: ${val}` }, - y: { formatter: (val: number) => `${val} companies` }, + x: { formatter: (val: any) => `Month: ${val ?? ""}` }, + y: { formatter: (val: number) => `${val ?? 0} companies` }, marker: { show: true }, }, @@ -2229,8 +2231,8 @@ const DealsDashboard = () => { shared: true, intersect: false, y: [ - { formatter: (val: any) => `${val} deals` }, - { formatter: (val: any) => `₹${val.toLocaleString()}` }, + { formatter: (val: any) => `${val ?? 0} deals` }, + { formatter: (val: any) => `₹${(val ?? 0).toLocaleString()}` }, ], }, @@ -2683,127 +2685,152 @@ const DealsDashboard = () => { style={{ width: `${scrollProgress}%` }} >
-
+
-
-
-
-
-
-

- - Admin Dashboard - acc + (item.lead_count || 0), 0) || allLeads.length} + contactedLeads={dashboardData?.statsData?.overall_lead_value_by_status_WITH_COUNT?.find((s: any) => s.status === "Contacted")?.lead_count || 0} + notContactedLeads={dashboardData?.statsData?.overall_lead_value_by_status_WITH_COUNT?.find((s: any) => s.status === "Not_Contacted")?.lead_count || 0} + dealsWon={dealStatusSummary.find((s: any) => s.name === "Won")?.value || 0} + dealsLost={dealStatusSummary.find((s: any) => s.name === "Lost")?.value || 0} + openDeals={dealStatusSummary.find((s: any) => s.name === "Open")?.value || 0} + totalDealValue={allDeals.reduce((sum, d) => sum + (parseFloat(d.deal_value as any) || 0), 0)} + conversionRate={conversionRate} + stages={stages} + stageOwnerCounts={stageOwnerCounts} + productRevenueData={productRevenueData} + dealSourceData={{ labels: chartConfig?.labels || [], series: chartConfig?.series || [] }} + allLeads={allLeads} + allDeals={allDeals} + todos={todos} + calendarEvents={calendarEvents || []} + navigate={navigate} + /> + ) : ( + <> +
+
+
+
+
+ Hala {userName || "Mohammad"}! +
+

- - -

-
-
-
-
-
- -
+ Welcome to CRM Dashboard +

+
+
+
+
-
- - - Welcome, {userName || "Admin"} - -
-
-
-
-
- {statusWidgets.map((widget, index) => { - const total = statusWidgets.reduce( - (sum, w) => sum + w.value, - 0 - ); - const percent = - total > 0 ? ((widget.value / total) * 100).toFixed(1) : 0; + {/* KPI Widget Grid */} +
+ {statusWidgets.map((widget, index) => { + const total = statusWidgets.reduce( + (sum, w) => sum + w.value, + 0 + ); + const percent = + total > 0 ? ((widget.value / total) * 100).toFixed(1) : 0; - return ( -
- -
{ - if (widget.label === "UnAssigned Contacts") { - navigate(`/crm/contact-list?unassigned=true`); - } else { - const statusParam = widget.label || ""; - navigate( - `/leads${statusParam + const accentClass = + widget.label === "Contacted" + ? "kpi-accent-warning" + : widget.label === "Not_Contacted" + ? "kpi-accent-info" + : widget.label === "Closed" + ? "kpi-accent-success" + : widget.label === "Lost" + ? "kpi-accent-danger" + : "kpi-accent-secondary"; + + return ( + +
{ + if ( + widget.label === "UnAssigned Contacts" || + widget.label === "Unassigned Contacts" + ) { + navigate(`/crm/contact-list?unassigned=true`); + } else { + const statusParam = widget.label || ""; + navigate( + `/leads${ + statusParam + ? `?status=${encodeURIComponent(statusParam)}` + : "" + }` + ); + } + }} + onKeyDown={(e) => { + if (e.key === "Enter" || e.key === " ") { + if ( + widget.label === "UnAssigned Contacts" || + widget.label === "Unassigned Contacts" + ) { + navigate(`/crm/contact-list?unassigned=true`); + } else { + const statusParam = widget.label || ""; + navigate( + `/leads${ + statusParam ? `?status=${encodeURIComponent(statusParam)}` : "" - }` - ); - } - }} - onMouseEnter={(e) => { - e.currentTarget.style.transform = "translateY(-4px)"; - e.currentTarget.style.boxShadow = - "0 6px 18px rgba(0,0,0,0.12)"; - }} - onMouseLeave={(e) => { - e.currentTarget.style.transform = "translateY(0px)"; - e.currentTarget.style.boxShadow = - "var(--bs-box-shadow-sm)"; - }} + }` + ); + } + } + }} + > +
+ -
- - {widget.icon} - -
+ {widget.subtext || widget.label} +
+
{widget.icon}
+
-

- -

-

{widget.subtext}

-
-
+
+

+ +

+ {total > 0 && ( + {percent}% + )} +
- ); - })} -
-
+ + ); + })} +
+ +
+
{ > {/* LEFT SIDE : TITLE + ICONS */}
- + Monthly Highlights
@@ -2937,22 +2964,22 @@ const DealsDashboard = () => {
-
+
-
-
+
-

- - Leads by Stage +
+ + Leads by Stage -
+

{ options={leadsByStageOptions.options} series={leadsByStageOptions.series} type="bar" - height={window.innerWidth < 576 ? 220 : 275} + height={240} />
{/* ===== STAGE → OWNER BREAKDOWN ===== */} -
+
{Object.entries(stageOwnerCounts).map( ([stage, owners], idx) => { const isOpen = openIndex === idx; @@ -3006,7 +3033,7 @@ const DealsDashboard = () => { ); return ( -
+

-
+
-
+
-

- - Product-wise Deal Revenue +
+ + Product Deal Revenue -
+

{

No revenue data available

) : ( -
+
- + { {(!activeKey || activeKey === "Won") && ( @@ -3227,18 +3256,19 @@ const DealsDashboard = () => {
{/* Deals by Source */} -
+
-
-

- Deals by Source +
+
+ + Deals by Source -
+

{ options={chartConfig} series={chartConfig.series} type="donut" - height={350} + height={240} /> )}
-
+
@@ -3384,7 +3414,7 @@ const DealsDashboard = () => {
-
+
🏅 Top 5 Performers Leaderboard @@ -3500,7 +3530,7 @@ const DealsDashboard = () => { )}
-
+
{/* Title */}
🕒 Lead Last Activity Overview @@ -4940,12 +4970,12 @@ const DealsDashboard = () => {
-
- {/* ================= HEADER ================= */} -
+
+ {/* ================= HEADER ================= */} +
@@ -5267,8 +5297,8 @@ const DealsDashboard = () => { {/* Deal Status Summary (Rose Chart) */}
-
-
+
+
Deal Status Summary @@ -5551,9 +5581,9 @@ const DealsDashboard = () => { {/*Sticky Notes*/}
-
+
{/* Header */} -
+
Upcoming Schedule @@ -5588,41 +5618,29 @@ const DealsDashboard = () => { const start = moment(event.event_start); const end = moment(event.event_end); - const bgColors = [ - "#E9EAFE", - "#FFF1DA", - "#D6F5E8", - "#FFE9E9", + const accentColors = [ + "#4F46E5", + "#059669", + "#D97706", + "#6366F1", ]; - const textColors = [ - "#706FE5", - "#F4A700", - "#38B77C", - "#F25C5C", - ]; - - const color = textColors[index % textColors.length]; - const bg = bgColors[index % bgColors.length]; + const color = accentColors[index % accentColors.length]; return (
setHoveredIndex(index)} onMouseLeave={() => setHoveredIndex(null)} style={{ - backgroundColor: bg, + backgroundColor: + hoveredIndex === index + ? "#f9fafb" + : "#ffffff", cursor: "pointer", - transform: - hoveredIndex === index - ? "scale(1.015)" - : "scale(1)", - boxShadow: - hoveredIndex === index - ? "0 4px 12px rgba(0,0,0,0.12)" - : "0 1px 4px rgba(0,0,0,0.08)", - transition: "all 0.25s ease", - borderLeft: `5px solid ${color}`, + border: "1px solid #e5e7eb", + borderLeft: `4px solid ${color}`, + transition: "all 0.2s ease", }} > {/* Date Block */} @@ -5720,9 +5738,9 @@ const DealsDashboard = () => {
-
+
{/* Header */} -
+
Recent ToDos @@ -5752,40 +5770,28 @@ const DealsDashboard = () => { todos.map((todo, index) => { const created = moment(todo.created_at); - const bgColors = [ - "#E9EAFE", - "#FFF1DA", - "#D6F5E8", - "#FFE9E9", + const accentColors = [ + "#4F46E5", + "#059669", + "#D97706", + "#6366F1", ]; - const textColors = [ - "#706FE5", - "#F4A700", - "#38B77C", - "#F25C5C", - ]; - - const bg = bgColors[index % bgColors.length]; - const color = textColors[index % textColors.length]; + const color = accentColors[index % accentColors.length]; return (
handleOpenTodo(todo)} style={{ - backgroundColor: bg, + backgroundColor: + hoveredTodo === index + ? "#f9fafb" + : "#ffffff", cursor: "pointer", - transition: "all 0.25s ease", - transform: - hoveredTodo === index - ? "scale(1.015)" - : "scale(1)", - boxShadow: - hoveredTodo === index - ? "0 4px 12px rgba(0,0,0,0.12)" - : "0 1px 4px rgba(0,0,0,0.06)", + border: "1px solid #e5e7eb", borderLeft: `4px solid ${color}`, + transition: "all 0.2s ease", }} onMouseEnter={() => setHoveredTodo(index)} onMouseLeave={() => setHoveredTodo(null)} @@ -6454,8 +6460,10 @@ const DealsDashboard = () => {
-
-
+ + )} +
+
{showScrollTop && (