Improve RFM recency labels
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m28s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m28s
This commit is contained in:
@@ -182,6 +182,13 @@ const Rfm = () => {
|
|||||||
return Math.max(0, Math.floor((rangeEndDay - purchaseDay) / DAY_MS));
|
return Math.max(0, Math.floor((rangeEndDay - purchaseDay) / DAY_MS));
|
||||||
}, [dateRange.end]);
|
}, [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 filteredClients = useMemo(() => {
|
||||||
const normalizedSearch = searchTerm.trim().toLowerCase();
|
const normalizedSearch = searchTerm.trim().toLowerCase();
|
||||||
|
|
||||||
@@ -245,7 +252,7 @@ const Rfm = () => {
|
|||||||
Recencia: client.recencyScore,
|
Recencia: client.recencyScore,
|
||||||
Frequencia: client.frequencyScore,
|
Frequencia: client.frequencyScore,
|
||||||
Monetario: client.monetaryScore,
|
Monetario: client.monetaryScore,
|
||||||
'Dias desde compra no periodo': getPeriodRecencyDays(client.lastPurchaseDate),
|
'Compra no periodo': formatPeriodRecency(client.lastPurchaseDate),
|
||||||
'Pedidos no periodo': client.frequency,
|
'Pedidos no periodo': client.frequency,
|
||||||
'Ticket medio no periodo (R$)': (client.frequency ? client.monetary / client.frequency : 0).toFixed(2).replace('.', ','),
|
'Ticket medio no periodo (R$)': (client.frequency ? client.monetary / client.frequency : 0).toFixed(2).replace('.', ','),
|
||||||
'Receita no periodo (R$)': client.monetary.toFixed(2).replace('.', ','),
|
'Receita no periodo (R$)': client.monetary.toFixed(2).replace('.', ','),
|
||||||
@@ -551,7 +558,7 @@ const Rfm = () => {
|
|||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-3 text-dark-muted font-medium">
|
<td className="px-6 py-3 text-dark-muted font-medium">
|
||||||
{formatDate(client.lastPurchaseDate)}
|
{formatDate(client.lastPurchaseDate)}
|
||||||
<span className="block text-xs">{getPeriodRecencyDays(client.lastPurchaseDate)} dias</span>
|
<span className="block text-xs">{formatPeriodRecency(client.lastPurchaseDate)}</span>
|
||||||
</td>
|
</td>
|
||||||
<td className="px-6 py-3 text-dark-text font-bold">{client.frequency}</td>
|
<td className="px-6 py-3 text-dark-text font-bold">{client.frequency}</td>
|
||||||
<td className="px-6 py-3 text-dark-text font-bold">{formatCurrency(client.frequency ? client.monetary / client.frequency : 0)}</td>
|
<td className="px-6 py-3 text-dark-text font-bold">{formatCurrency(client.frequency ? client.monetary / client.frequency : 0)}</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user