Keep client data visible when RFV fails
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m24s

This commit is contained in:
Cauê Faleiros
2026-06-17 11:23:46 -03:00
parent 4b3d65587e
commit f88ae2d491
2 changed files with 133 additions and 14 deletions

View File

@@ -7,6 +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',
'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',
@@ -19,6 +20,7 @@ const clientTypeStyles: Record<string, string> = {
};
const clientTypes = [
'Sem análise',
'Campeão',
'Potencial Leal',
'Novo Cliente',
@@ -81,12 +83,13 @@ const Clients = () => {
let isMounted = true;
const loadClients = async () => {
const [clientsData, rfmData] = await Promise.all([
fetchClientAnalytics(dateRange),
fetchRfmAnalytics(dateRange)
]);
const clientsData = await fetchClientAnalytics(dateRange);
if (isMounted) {
setClientAnalytics(clientsData);
}
const rfmData = await fetchRfmAnalytics(dateRange);
if (isMounted) {
setRfmAnalytics(rfmData);
}
};
@@ -111,7 +114,7 @@ const Clients = () => {
totalItems: client.quantityPurchased,
orderCount: client.orderCount,
lastPurchase: client.lastPurchaseDate ? new Date(client.lastPurchaseDate).getTime() : 0,
clientType: rfmClient ? (backendSegmentToClientType[rfmClient.segmentKey] || rfmClient.segmentLabel) : 'Perdido',
clientType: rfmClient ? (backendSegmentToClientType[rfmClient.segmentKey] || rfmClient.segmentLabel) : 'Sem análise',
rfmScore: rfmClient?.rfmScore || '000',
rfmPriority: rfmClient ? getRfmPriority(rfmClient) : 0
};