Optimize client details with opaque tokens
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m20s

This commit is contained in:
Cauê Faleiros
2026-06-22 11:00:42 -03:00
parent 3c74fa7210
commit 0874238fc6
12 changed files with 548 additions and 43 deletions

View File

@@ -13,6 +13,7 @@ export type ClientSortOption =
export interface ClientSummary {
customerKey: string;
clientToken: string;
name: string;
phone: string;
totalSpent: number;
@@ -98,6 +99,7 @@ const enrichClientsWithRfmType = (
return {
...client,
clientToken: client.clientToken || client.customerKey,
averageTicket: client.orderCount ? client.totalSpent / client.orderCount : 0,
clientType: getClientType(recencyScore, valueScore),
rfmScore: `${recencyScore}${frequencyScore}${monetaryScore}`,
@@ -147,6 +149,7 @@ export const buildClientsSummary = (
const normalizedSearch = searchTerm.trim().toLowerCase();
const clients = enrichClientsWithRfmType(Object.keys(clientMap).map(customerKey => ({
customerKey,
clientToken: customerKey,
name: clientMap[customerKey].name,
phone: clientMap[customerKey].phone,
totalSpent: clientMap[customerKey].totalSpent,