From 9a58b2a271bd744f575e3703fec8a9552b567e06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cau=C3=AA=20Faleiros?= Date: Mon, 15 Jun 2026 15:55:33 -0300 Subject: [PATCH] Improve RFM recency labels --- src/pages/Rfm.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/pages/Rfm.tsx b/src/pages/Rfm.tsx index dff706c..80e3e5a 100644 --- a/src/pages/Rfm.tsx +++ b/src/pages/Rfm.tsx @@ -182,6 +182,13 @@ const Rfm = () => { return Math.max(0, Math.floor((rangeEndDay - purchaseDay) / DAY_MS)); }, [dateRange.end]); + const formatPeriodRecency = useCallback((lastPurchaseDate: string) => { + const days = getPeriodRecencyDays(lastPurchaseDate); + if (days === 0) return 'Hoje'; + if (days === 1) return 'Ontem'; + return `${days} dias`; + }, [getPeriodRecencyDays]); + const filteredClients = useMemo(() => { const normalizedSearch = searchTerm.trim().toLowerCase(); @@ -245,7 +252,7 @@ const Rfm = () => { Recencia: client.recencyScore, Frequencia: client.frequencyScore, Monetario: client.monetaryScore, - 'Dias desde compra no periodo': getPeriodRecencyDays(client.lastPurchaseDate), + 'Compra no periodo': formatPeriodRecency(client.lastPurchaseDate), 'Pedidos no periodo': client.frequency, 'Ticket medio no periodo (R$)': (client.frequency ? client.monetary / client.frequency : 0).toFixed(2).replace('.', ','), 'Receita no periodo (R$)': client.monetary.toFixed(2).replace('.', ','), @@ -551,7 +558,7 @@ const Rfm = () => { {formatDate(client.lastPurchaseDate)} - {getPeriodRecencyDays(client.lastPurchaseDate)} dias + {formatPeriodRecency(client.lastPurchaseDate)} {client.frequency} {formatCurrency(client.frequency ? client.monetary / client.frequency : 0)}