fix: use robust date parsing utility to handle varying n8n date formats
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m26s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 2m26s
This commit is contained in:
@@ -3,6 +3,7 @@ import { Link, useOutletContext } from 'react-router-dom';
|
||||
import { Search, Package, TrendingUp } from 'lucide-react';
|
||||
import DateRangePicker from '../components/DateRangePicker';
|
||||
import type { OrderData, DateRange } from '../types';
|
||||
import { parseOrderDate } from '../dataService';
|
||||
|
||||
const Products = () => {
|
||||
const { dateRange, setDateRange, ordersData } = useOutletContext<{ dateRange: DateRange, setDateRange: (range: DateRange) => void, ordersData: OrderData[] }>();
|
||||
@@ -13,8 +14,7 @@ const Products = () => {
|
||||
const productMap: Record<string, { id: string, name: string, totalSold: number, revenue: number, lastPrice: number }> = {};
|
||||
|
||||
orders.forEach(order => {
|
||||
const [day, month, year] = order.Data_Pedido.split('-').map(Number);
|
||||
const orderDate = new Date(year, month - 1, day);
|
||||
const orderDate = parseOrderDate(order.Data_Pedido);
|
||||
if (orderDate < dateRange.start || orderDate > dateRange.end) return;
|
||||
|
||||
if (!productMap[order.ID_Produto]) {
|
||||
|
||||
Reference in New Issue
Block a user