UNPKG

@kiwicom/smart-faq

Version:

Smart FAQ

73 lines (61 loc) 1.75 kB
/*:: import type { Props as FuturePaginationRelayTypes } from './FutureBookingsPaginationContainer';*/ /*:: import type { Props as PastPaginationRelayTypes } from './PastBookingsPaginationContainer';*/ /*:: type PaginatorPropsType = { props: FuturePaginationRelayTypes | PastPaginationRelayTypes, +setState: (state?: Object, callback?: () => void) => void, };*/ "use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.createPaginator = exports.getVariables = exports.getFragmentVariables = void 0; var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread")); // @flow var getFragmentVariables = function getFragmentVariables(prevVars /*: Object*/ , totalCount /*: number*/ ) { return ( /*: Object*/ (0, _objectSpread2.default)({}, prevVars, { count: totalCount }) ); }; exports.getFragmentVariables = getFragmentVariables; var getVariables = function getVariables(props /*: Object*/ , _ref, variables /*: Object*/ ) { var count = _ref.count, cursor = _ref.cursor; return ( /*: Object*/ { first: count, after: cursor, brand: variables.brand } ); }; exports.getVariables = getVariables; var createPaginator = function createPaginator(paginatorProps /*: PaginatorPropsType*/ ) { var relay = paginatorProps.props.relay; if (relay.hasMore() && !relay.isLoading()) { paginatorProps.setState({ isLoading: true }, function () { relay.loadMore(3, function () { paginatorProps.setState({ isLoading: false }); }); }); } }; exports.createPaginator = createPaginator;