fix: unique reference for filter items

This commit is contained in:
Carlos Valente
2025-02-18 11:51:34 +01:00
committed by Carlos Valente
parent 1636745fed
commit 636f78e21e
@@ -181,7 +181,7 @@ export default function AutomationForm(props: AutomationFormProps) {
</div> </div>
<div className={style.innerSection}> <div className={style.innerSection}>
<h3>Filters</h3> <h3>Filters (optional)</h3>
<div className={style.ruleSection}> <div className={style.ruleSection}>
<label> <label>
Trigger outputs if Trigger outputs if
@@ -196,8 +196,10 @@ export default function AutomationForm(props: AutomationFormProps) {
)} )}
/> />
</label> </label>
{fieldFilters.map((field, index) => ( {fieldFilters.map((field, index) => {
<div key={field.id} className={style.filterSection}> const key = `filters.${index}.field.${field.id}`;
return (
<div key={key} className={style.filterSection}>
<label> <label>
Runtime data source Runtime data source
<Select <Select
@@ -208,11 +210,14 @@ export default function AutomationForm(props: AutomationFormProps) {
<option selected hidden disabled value=''> <option selected hidden disabled value=''>
Event field Event field
</option> </option>
{fieldList.map(({ value, label }) => ( {fieldList.map(({ value, label }, localIndex) => {
<option key={value} value={value}> const key = `filters.${index}.field.${localIndex}`;
return (
<option key={key} value={value}>
{label} {label}
</option> </option>
))} );
})}
</Select> </Select>
<Panel.Error>{errors.filters?.[index]?.field?.message}</Panel.Error> <Panel.Error>{errors.filters?.[index]?.field?.message}</Panel.Error>
</label> </label>
@@ -263,7 +268,8 @@ export default function AutomationForm(props: AutomationFormProps) {
</div> </div>
</div> </div>
</div> </div>
))} );
})}
<div> <div>
<Button <Button
variant='ontime-subtle' variant='ontime-subtle'