Fix client detail customer identity
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 1m17s

This commit is contained in:
Cauê Faleiros
2026-06-18 16:31:22 -03:00
parent 1af624aa77
commit c35f8f8a51
8 changed files with 173 additions and 36 deletions

View File

@@ -1,8 +1,21 @@
import type { DateRange, OrderData } from '../types';
import { parseOrderDate } from '../dataService';
import type { DateRange, OrderData } from '../types.ts';
const SIZE_SUFFIX_PATTERN = /\s+-\s+(?:(?:PP|P|M|G|GG|XG|XGG|EG|EGG|EXG|U|UNICO|ÚNICO|\d{2})(?:\/(?:PP|P|M|G|GG|XG|XGG|EG|EGG|EXG|U|UNICO|ÚNICO|\d{2}))*)$/i;
export const parseOrderDate = (dateStr: string): Date => {
if (!dateStr) return new Date(0);
if (dateStr.includes('T')) return new Date(dateStr);
const parts = dateStr.split(/[-/]/);
if (parts.length === 3) {
if (parts[0].length === 4) {
return new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
}
return new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
}
const fallback = new Date(dateStr);
return Number.isNaN(fallback.getTime()) ? new Date(0) : fallback;
};
export const getBaseProductName = (description: string): string => {
const productName = description.trim();
if (productName.toLocaleUpperCase('pt-BR').startsWith('ETIQUETA')) {
@@ -13,7 +26,11 @@ export const getBaseProductName = (description: string): string => {
};
export const getClientDisplayName = (order: OrderData): string => {
return order.Nome_Cliente || `Cliente Desconhecido (Pedido ${order.Valor_Pedido})`;
return order.Nome_Cliente || 'Cliente Desconhecido';
};
export const getOrderCustomerKey = (order: OrderData): string => {
return order.Fone_Cliente || `name:${getClientDisplayName(order)}`;
};
export const isOrderInDateRange = (order: OrderData, dateRange: DateRange): boolean => {