"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.handleManagementNetworkRequests = handleManagementNetworkRequests;
const managementNetworkCommands_1 = require("./managementNetworkCommands");
function handleManagementNetworkRequests(onCommand, dispatch, frontApplet) {
    onCommand(async (commandEvent) => {
        switch (commandEvent.command.type) {
            case managementNetworkCommands_1.ManagementNetworkListInterfacesRequest:
                await dispatch({
                    type: managementNetworkCommands_1.ManagementNetworkListInterfacesResult,
                    result: await frontApplet.management.network.listInterfaces(),
                });
                break;
            case managementNetworkCommands_1.ManagementNetworkSetManualRequest:
                await frontApplet.management.network.setManual(commandEvent.command.interfaceName, commandEvent.command.options);
                await dispatch({
                    type: managementNetworkCommands_1.ManagementNetworkSetManualResult,
                    result: {},
                });
                break;
            case managementNetworkCommands_1.ManagementNetworkSetDHCPServerRequest:
                await frontApplet.management.network.setDHCP(commandEvent.command.interfaceName);
                await dispatch({
                    type: managementNetworkCommands_1.ManagementNetworkSetDHCPServerResult,
                    result: {},
                });
                break;
            case managementNetworkCommands_1.ManagementNetworkDisableInterfaceRequest:
                await frontApplet.management.network.disableInterface(commandEvent.command.interfaceName);
                await dispatch({
                    type: managementNetworkCommands_1.ManagementNetworkDisableInterfaceResult,
                    result: {},
                });
                break;
            default:
        }
    });
}
//# sourceMappingURL=handleManagementNetworkRequests.js.map