+ Classificação RFM sincronizada com a página RFM quando disponível. +
+| Posição | Nome do Cliente | +Tipo | +RFM | Total Gasto | +Ticket Médio | Produtos Comprados | Ações | {client.name} | ++ + {client.clientType} + + | +
+
+ {client.rfmScore.split('').map((score, scoreIndex) => (
+
+ {score}
+
+ ))}
+
+ |
{formatCurrency(client.totalSpent)} | +{formatCurrency(client.averageTicket)} | {client.totalItems} un. ({client.orderCount} {client.orderCount === 1 ? 'pedido' : 'pedidos'}) | diff --git a/src/pages/Rfm.tsx b/src/pages/Rfm.tsx new file mode 100644 index 0000000..d860944 --- /dev/null +++ b/src/pages/Rfm.tsx @@ -0,0 +1,740 @@ +import { useCallback, useEffect, useMemo, useState } from 'react'; +import { Link, useOutletContext } from 'react-router-dom'; +import { Database, Download, Filter, Loader2, Search, Sparkles, Users } from 'lucide-react'; +import DateRangePicker from '../components/DateRangePicker'; +import { exportToCSV, fetchRfmAnalytics } from '../dataService'; +import type { DateRange, RfmAnalytics, RfmClient, RfmSegment } from '../types'; + +const emptyClients: RfmClient[] = []; +const emptySegments: RfmSegment[] = []; + +const segmentStyles: Record
|---|
| Cliente | +Segmento | +RFM | +Última Compra | +Pedidos | +Ticket Médio | +Total Gasto | +
|---|---|---|---|---|---|---|
|
+ {isDemoMode ? (
+
+
+
+ ) : (
+
+
+ |
+ + + + {client.segmentLabel} + + | +
+
+
+ |
+ + {formatDate(client.lastPurchaseDate)} + {client.recencyDays} dias + | +{client.frequency} | +{formatCurrency(client.frequency ? client.monetary / client.frequency : 0)} | +{formatCurrency(client.monetary)} | +