Rollback analytics to ed1f129b07
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m5s

This commit is contained in:
Cauê Faleiros
2026-06-17 12:13:48 -03:00
parent aedfedca76
commit 10c69457ba
8 changed files with 78 additions and 239 deletions

View File

@@ -7,7 +7,7 @@ import DateRangePicker from '../components/DateRangePicker';
import type { ClientSortOption, ClientSummary } from '../analytics/clients';
const clientTypeStyles: Record<string, string> = {
'Sem análise': 'border-zinc-500/30 bg-zinc-500/15 text-zinc-300',
'Sem análise': 'border-zinc-600/30 bg-zinc-600/15 text-zinc-300',
'Campeão': 'border-emerald-500/30 bg-emerald-500/15 text-emerald-300',
'Potencial Leal': 'border-sky-500/30 bg-sky-500/15 text-sky-300',
'Novo Cliente': 'border-cyan-500/30 bg-cyan-500/15 text-cyan-300',
@@ -83,13 +83,12 @@ const Clients = () => {
let isMounted = true;
const loadClients = async () => {
const clientsData = await fetchClientAnalytics(dateRange);
const [clientsData, rfmData] = await Promise.all([
fetchClientAnalytics(dateRange),
fetchRfmAnalytics(dateRange)
]);
if (isMounted) {
setClientAnalytics(clientsData);
}
const rfmData = await fetchRfmAnalytics(dateRange);
if (isMounted) {
setRfmAnalytics(rfmData);
}
};
@@ -103,9 +102,9 @@ const Clients = () => {
const allClientsData = useMemo(() => {
const normalizedSearch = searchTerm.trim().toLowerCase();
const rfmByCustomerKey = new Map((rfmAnalytics?.clients || []).map(client => [client.customerKey, client]));
const rfmByPhone = new Map((rfmAnalytics?.clients || []).map(client => [client.phone, client]));
const clients = clientAnalytics.map((client): ClientSummary => {
const rfmClient = rfmByCustomerKey.get(client.customerKey);
const rfmClient = client.phone ? rfmByPhone.get(client.phone) : undefined;
return {
name: client.name,
phone: client.phone,