Use all-time client purchase patterns
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m25s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m25s
This commit is contained in:
@@ -260,14 +260,21 @@ export const buildClientDetailsMetrics = (ordersData: OrderData[], customerKey:
|
||||
value: 0
|
||||
}));
|
||||
|
||||
groupedOrders.forEach(group => {
|
||||
const firstItem = group.items[0];
|
||||
const orderDate = parseOrderDate(group.date);
|
||||
const patternOrders = new Map<string, OrderData>();
|
||||
clientOrders.forEach(order => {
|
||||
const key = order.ID_Pedido || `${order.Data_Pedido}_${order.Valor_Pedido}`;
|
||||
if (!patternOrders.has(key)) {
|
||||
patternOrders.set(key, order);
|
||||
}
|
||||
});
|
||||
|
||||
patternOrders.forEach(order => {
|
||||
const orderDate = parseOrderDate(order.Data_Pedido);
|
||||
if (!Number.isNaN(orderDate.getTime())) {
|
||||
weekdayCounts[orderDate.getDay()].value += 1;
|
||||
}
|
||||
|
||||
const orderHour = firstItem ? getOrderHour(firstItem) : null;
|
||||
const orderHour = getOrderHour(order);
|
||||
if (orderHour !== null) {
|
||||
hourCounts[orderHour].value += 1;
|
||||
}
|
||||
|
||||
@@ -291,9 +291,14 @@ const ClientDetails = () => {
|
||||
</div>
|
||||
|
||||
<section className="space-y-4">
|
||||
<div>
|
||||
<h3 className="text-lg font-bold text-zinc-900 dark:text-dark-text">Padrão de Compra</h3>
|
||||
<p className="mt-1 text-sm font-medium text-zinc-500 dark:text-dark-muted">Quando este cliente costuma comprar.</p>
|
||||
<div className="flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between">
|
||||
<div>
|
||||
<h3 className="text-lg font-bold text-zinc-900 dark:text-dark-text">Padrão de Compra</h3>
|
||||
<p className="mt-1 text-sm font-medium text-zinc-500 dark:text-dark-muted">Quando este cliente costuma comprar.</p>
|
||||
</div>
|
||||
<span className="w-fit rounded-full border border-zinc-200 bg-white px-3 py-1 text-xs font-bold uppercase tracking-wide text-zinc-500 dark:border-dark-border dark:bg-dark-card dark:text-dark-muted">
|
||||
Todo período
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
|
||||
Reference in New Issue
Block a user