"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var _exportNames = { pingStatusReducer: true }; exports.pingStatusReducer = void 0; var _toolkit = require("@reduxjs/toolkit"); var _actions = require("./actions"); Object.keys(_actions).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _actions[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function () { return _actions[key]; } }); }); var _effects = require("./effects"); Object.keys(_effects).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _effects[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function () { return _effects[key]; } }); }); var _selectors = require("./selectors"); Object.keys(_selectors).forEach(function (key) { if (key === "default" || key === "__esModule") return; if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return; if (key in exports && exports[key] === _selectors[key]) return; Object.defineProperty(exports, key, { enumerable: true, get: function () { return _selectors[key]; } }); }); /* * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ const initialState = { pingStatuses: {}, loading: false, error: null }; const pingStatusReducer = (0, _toolkit.createReducer)(initialState, builder => { builder.addCase(_actions.getMonitorPingStatusesAction.get, state => { state.loading = true; }).addCase(_actions.getMonitorPingStatusesAction.success, (state, action) => { var _action$payload$pings; ((_action$payload$pings = action.payload.pings) !== null && _action$payload$pings !== void 0 ? _action$payload$pings : []).forEach(ping => { // eslint-disable-next-line @typescript-eslint/naming-convention const { config_id, locationId, timestamp } = ping; if (!state.pingStatuses[config_id]) { state.pingStatuses[config_id] = {}; } if (!state.pingStatuses[config_id][locationId]) { state.pingStatuses[config_id][locationId] = {}; } state.pingStatuses[config_id][locationId][timestamp] = ping; }); state.loading = false; }).addCase(_actions.getMonitorPingStatusesAction.fail, (state, action) => { state.error = action.payload; state.loading = false; }); }); exports.pingStatusReducer = pingStatusReducer;