Skip to content

Commit

Permalink
fix property saving in paymentalerts'
Browse files Browse the repository at this point in the history
  • Loading branch information
stCarolas committed Feb 6, 2024
1 parent 5364583 commit ff598d1
Showing 1 changed file with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,12 +249,12 @@ export default function PaymentAlertSettings({
}

function deleteAlert() {
const alerts = config.get(id)?.alerts;
const oldConfig = config.get(id) ?? {};
const alerts = oldConfig?.alerts ?? [];
alerts.splice(selected, 1);
oldConfig.alerts = alerts;
setConfig(
new Map(config).set(id, {
alerts: alerts,
}),
new Map(config).set(id, oldConfig),
);
}

Expand Down Expand Up @@ -312,8 +312,8 @@ export default function PaymentAlertSettings({

function update(key: string, value: any) {
setConfig((oldConfig) => {
let updatedProperties = oldConfig
.get(id)
const widgetConfig = oldConfig.get(id) ?? {};
let updatedProperties = widgetConfig
?.alerts?.at(selected)
?.properties.map((it) => {
if (it.name === key) {
Expand All @@ -329,7 +329,8 @@ export default function PaymentAlertSettings({
}
return it;
});
return new Map(oldConfig).set(id, { alerts: updatedAlerts });
widgetConfig.alerts = updatedAlerts;
return new Map(oldConfig).set(id, widgetConfig);
});
onChange.call({});
}
Expand Down

0 comments on commit ff598d1

Please sign in to comment.