fix: ensure proper status in add charging stations op response
[e-mobility-charging-stations-simulator.git] / src / charging-station / ui-server / ui-services / AbstractUIService.ts
index 3fa3f8ba756782567755b9a24c4dcf883de99489..ffdc256583adccd581d72c99496e3bfe726333e2 100644 (file)
@@ -301,8 +301,10 @@ export abstract class AbstractUIService {
       }
     }
     return {
-      status: failedStationInfos.length > 0 ? ResponseStatus.FAILURE : ResponseStatus.SUCCESS,
-      hashIdsSucceeded: succeededStationInfos.map(stationInfo => stationInfo.hashId),
+      status: err != null ? ResponseStatus.FAILURE : ResponseStatus.SUCCESS,
+      ...(succeededStationInfos.length > 0 && {
+        hashIdsSucceeded: succeededStationInfos.map(stationInfo => stationInfo.hashId)
+      }),
       ...(failedStationInfos.length > 0 && {
         hashIdsFailed: failedStationInfos.map(stationInfo => stationInfo.hashId)
       }),