"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.RequestList = RequestList;
var _reactNative = require("react-native");
var _RequestItem = require("../RequestItem");
var _styles = require("./styles");
var _components = require("../../../../../components");
function ItemSeparator() {
  const {
    styles
  } = (0, _styles.useStyles)();
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.divider
  });
}
function RequestList({
  requests,
  hasMore,
  loadMore,
  isLoading,
  isLoadingFirstPage
}) {
  const {
    styles
  } = (0, _styles.useStyles)();
  return /*#__PURE__*/React.createElement(_reactNative.FlatList, {
    data: requests,
    keyExtractor: item => item.from,
    ItemSeparatorComponent: ItemSeparator,
    contentContainerStyle: styles.container,
    renderItem: ({
      item
    }) => /*#__PURE__*/React.createElement(_RequestItem.RequestItem, {
      userId: item.from
    }),
    ListEmptyComponent: !isLoading && !isLoadingFirstPage ? /*#__PURE__*/React.createElement(_components.Empty, {
      heightPercent: 0.8
    }, /*#__PURE__*/React.createElement(_components.Empty.Content, {
      icon: "review",
      title: "No requests to review"
    })) : null,
    ListFooterComponent: isLoading || isLoadingFirstPage ? /*#__PURE__*/React.createElement(React.Fragment, null, Array.from({
      length: 3
    }).map((_, index) => /*#__PURE__*/React.createElement(_RequestItem.RequestItem.Skeleton, {
      key: index
    }))) : null,
    onEndReached: () => {
      if (hasMore && !isLoading && !isLoadingFirstPage) {
        loadMore === null || loadMore === void 0 || loadMore();
      }
    }
  });
}
//# sourceMappingURL=RequestList.js.map