fix: add safe generic fallback to date parsers to prevent parse errors

This commit is contained in:
Christian Vidal Wolf
2026-02-21 19:44:18 +01:00
parent aa9a7845b7
commit 9259129f95
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -72,7 +72,8 @@ const ExperimentDetail: React.FC<ExperimentDetailProps> = ({ experimentId, onClo
const productBreakdown = useMemo(() => {
if (!experiment || targetAsins.length <= 1 || !salesData.length) return null;
const parseDate = (d: string) => {
const parseDate = (d?: string) => {
if (!d) return new Date();
const [y, m, da] = d.split('T')[0].split('-');
return new Date(Number(y), Number(m) - 1, Number(da));
};
+2 -1
View File
@@ -232,7 +232,8 @@ export const calculateExperimentPerformance = async (
experiment_acos: number;
actual_lift_percent: number;
}> => {
const parseLocalDate = (dateStr: string) => {
const parseLocalDate = (dateStr?: string) => {
if (!dateStr) return new Date();
const [y, m, d] = dateStr.split('T')[0].split('-');
return new Date(Number(y), Number(m) - 1, Number(d));
};