Score RFV clients without phone
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m46s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m46s
This commit is contained in:
@@ -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
|
||||
};
|
||||
|
||||
@@ -64,6 +64,7 @@ export interface DashboardAnalytics {
|
||||
}
|
||||
|
||||
export interface ClientAnalyticsItem {
|
||||
customerKey: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
quantityPurchased: number;
|
||||
@@ -73,6 +74,7 @@ export interface ClientAnalyticsItem {
|
||||
}
|
||||
|
||||
export interface RfmClient {
|
||||
customerKey: string;
|
||||
name: string;
|
||||
phone: string;
|
||||
monetary: number;
|
||||
|
||||
Reference in New Issue
Block a user