Score RFV clients without phone
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m46s

This commit is contained in:
Cauê Faleiros
2026-06-17 09:59:57 -03:00
parent ed1f129b07
commit ce72231560
4 changed files with 29 additions and 20 deletions

View File

@@ -7,7 +7,6 @@ import DateRangePicker from '../components/DateRangePicker';
import type { ClientSortOption, ClientSummary } from '../analytics/clients';
const clientTypeStyles: Record<string, string> = {
'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',
@@ -20,7 +19,6 @@ const clientTypeStyles: Record<string, string> = {
};
const clientTypes = [
'Sem análise',
'Campeão',
'Potencial Leal',
'Novo Cliente',
@@ -102,9 +100,9 @@ const Clients = () => {
const allClientsData = useMemo(() => {
const normalizedSearch = searchTerm.trim().toLowerCase();
const rfmByPhone = new Map((rfmAnalytics?.clients || []).map(client => [client.phone, client]));
const rfmByCustomerKey = new Map((rfmAnalytics?.clients || []).map(client => [client.customerKey, client]));
const clients = clientAnalytics.map((client): ClientSummary => {
const rfmClient = client.phone ? rfmByPhone.get(client.phone) : undefined;
const rfmClient = rfmByCustomerKey.get(client.customerKey);
return {
name: client.name,
phone: client.phone,
@@ -113,7 +111,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) : 'Sem análise',
clientType: rfmClient ? (backendSegmentToClientType[rfmClient.segmentKey] || rfmClient.segmentLabel) : 'Perdido',
rfmScore: rfmClient?.rfmScore || '000',
rfmPriority: rfmClient ? getRfmPriority(rfmClient) : 0
};