fix(ui): fix path to configuration file template
[e-mobility-charging-stations-simulator.git] / src / charging-station / broadcast-channel / ChargingStationWorkerBroadcastChannel.ts
index c464f9ca11d33222925f2ee0bf52c19fa37f8948..26aa61d38e7c97149877fcb13584715afc430d34 100644 (file)
@@ -86,6 +86,12 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
           await this.chargingStation.stop()
         }
       ],
+      [
+        BroadcastChannelProcedureName.DELETE_CHARGING_STATIONS,
+        async (requestPayload?: BroadcastChannelRequestPayload) => {
+          await this.chargingStation.delete(requestPayload?.deleteConfiguration as boolean)
+        }
+      ],
       [
         BroadcastChannelProcedureName.OPEN_CONNECTION,
         () => {
@@ -285,8 +291,6 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
       return
     }
     let responsePayload: BroadcastChannelResponsePayload | undefined
-    // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
-    let commandResponse: CommandResponse | void
     this.commandHandler(command, requestPayload)
       .then(commandResponse => {
         if (commandResponse == null || isEmptyObject(commandResponse)) {
@@ -312,12 +316,10 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
           status: ResponseStatus.FAILURE,
           command,
           requestPayload,
-          // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
-          commandResponse: commandResponse!,
           errorMessage: (error as OCPPError).message,
           errorStack: (error as OCPPError).stack,
           errorDetails: (error as OCPPError).details
-        }
+        } satisfies BroadcastChannelResponsePayload
       })
       .finally(() => {
         // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
@@ -345,7 +347,10 @@ export class ChargingStationWorkerBroadcastChannel extends WorkerBroadcastChanne
         return await commandHandler(requestPayload)
       }
       return (
-        commandHandler as (requestPayload?: BroadcastChannelRequestPayload) => CommandResponse
+        commandHandler as (
+          requestPayload?: BroadcastChannelRequestPayload
+          // eslint-disable-next-line @typescript-eslint/no-invalid-void-type
+        ) => CommandResponse | void
       )(requestPayload)
     }
     throw new BaseError(`Unknown worker broadcast channel command: '${command}'`)