diff --git a/frontend/src/components/MainComponent/MainComponent.tsx b/frontend/src/components/MainComponent/MainComponent.tsx index 220564b4..528c23bd 100644 --- a/frontend/src/components/MainComponent/MainComponent.tsx +++ b/frontend/src/components/MainComponent/MainComponent.tsx @@ -226,6 +226,13 @@ function MainComponent({ configItemId, currentLevel ); + if (!resetDefence) { + addChatMessage({ + message: 'Failed to reset defence configuration. Please try again.', + type: 'ERROR_MSG', + }); + return; + } addConfigUpdateToChat(defenceId, 'reset'); // update state const newDefences = defences.map((defence) => { diff --git a/frontend/src/service/defenceService.ts b/frontend/src/service/defenceService.ts index cfe45390..933fad18 100644 --- a/frontend/src/service/defenceService.ts +++ b/frontend/src/service/defenceService.ts @@ -75,13 +75,19 @@ async function resetDefenceConfigItem( defenceId: DEFENCE_ID, configItemId: DEFENCE_CONFIG_ITEM_ID, level: LEVEL_NAMES -): Promise { - const response = await post(`${PATH}/resetConfig`, { +): Promise { + return post(`${PATH}/resetConfig`, { defenceId, configItemId, level, - }); - return (await response.json()) as DefenceResetResponse; + }).then( + async (response) => { + return (await response.json()) as DefenceResetResponse; + }, + () => { + return null; + } + ); } function validatePositiveNumberConfig(value: string) {