@mopinion/survey
Version:
Collect customer feedback with the Mopinion survey library
29 lines (28 loc) • 1.29 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = usePrevVisiblePageNumber;
var _BlockStore = require("../stores/BlockStore");
var _ConfigStore = require("../stores/ConfigStore");
var _usePages = _interopRequireDefault(require("./usePages"));
var _constants = require("../../../constants");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function usePrevVisiblePageNumber(pageNumber) {
var blockState = (0, _BlockStore.useBlockStore)();
var _useConfigStore = (0, _ConfigStore.useConfigStore)(),
blocks = _useConfigStore.blocks;
var pages = (0, _usePages["default"])();
for (var i = pageNumber - 2; i >= 0; i--) {
var blockIds = pages[i];
var visibleBlocks = blockIds === null || blockIds === void 0 ? void 0 : blockIds.some(function (id) {
var _blockState$id, _blocks$id;
return ((_blockState$id = blockState[id]) === null || _blockState$id === void 0 ? void 0 : _blockState$id.isVisible) && _constants.alwaysNotVisibleBlocks.indexOf((_blocks$id = blocks[id]) === null || _blocks$id === void 0 ? void 0 : _blocks$id.typeName) === -1;
});
if (visibleBlocks) {
return i + 1;
}
}
return null;
}
//# sourceMappingURL=usePrevVisiblePageNumber.js.map