mirror of
https://github.com/christianvidalwolf-prog/CrazeAnalytix.git
synced 2026-08-03 18:55:24 +02:00
fix: sanitize experiment form data to prevent save failure on empty dates
This commit is contained in:
@@ -66,7 +66,16 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
|||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
try {
|
try {
|
||||||
await createExperiment(formData);
|
// Sanitize optional fields
|
||||||
|
const submissionData = {
|
||||||
|
...formData,
|
||||||
|
end_date: formData.end_date || undefined,
|
||||||
|
description: formData.description || undefined,
|
||||||
|
hypothesis: formData.hypothesis || undefined,
|
||||||
|
owner: formData.owner || undefined,
|
||||||
|
};
|
||||||
|
|
||||||
|
await createExperiment(submissionData);
|
||||||
onSuccess();
|
onSuccess();
|
||||||
onClose();
|
onClose();
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
@@ -174,8 +183,8 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
|||||||
setSelectedLine('');
|
setSelectedLine('');
|
||||||
}}
|
}}
|
||||||
className={`flex-1 px-3 py-2 rounded-lg text-xs font-bold border transition-all ${targetType === 'asin'
|
className={`flex-1 px-3 py-2 rounded-lg text-xs font-bold border transition-all ${targetType === 'asin'
|
||||||
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
||||||
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
🎯 Specific ASINs
|
🎯 Specific ASINs
|
||||||
@@ -188,8 +197,8 @@ const ExperimentForm: React.FC<ExperimentFormProps> = ({
|
|||||||
setAsinInput('');
|
setAsinInput('');
|
||||||
}}
|
}}
|
||||||
className={`flex-1 px-3 py-2 rounded-lg text-xs font-bold border transition-all ${targetType === 'line'
|
className={`flex-1 px-3 py-2 rounded-lg text-xs font-bold border transition-all ${targetType === 'line'
|
||||||
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
? 'bg-indigo-600/20 border-indigo-500 text-indigo-400'
|
||||||
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
: 'bg-slate-800 border-slate-600 text-slate-400 hover:border-slate-500'
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
📦 Entire Product Line
|
📦 Entire Product Line
|
||||||
|
|||||||
Reference in New Issue
Block a user