"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.PollFooter = PollFooter;
var _style = require("./style");
var _reactNative = require("react-native");
var _Typography = require("../../../core/components/Typography/Typography");
var _tsSdkReactNative = require("@amityco/ts-sdk-react-native");
var _time = require("../../../core/utils/time");
function PollFooter({
  post,
  poll,
  totalVotes,
  isPollClosed,
  isAlreadyVoted,
  isAuthorSeeingResults,
  setIsAuthorSeeingResults,
  unvotePoll,
  disabledPoll
}) {
  var _post$creator;
  const {
    styles
  } = (0, _style.useStyles)();
  const {
    userId
  } = _tsSdkReactNative.Client.getActiveUser();
  const isAuthor = (post === null || post === void 0 || (_post$creator = post.creator) === null || _post$creator === void 0 ? void 0 : _post$creator.userId) === userId;
  const isInReview = (post === null || post === void 0 ? void 0 : post.feedType) === 'reviewing';
  return /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.footer
  }, /*#__PURE__*/React.createElement(_reactNative.View, {
    style: styles.pollInfo
  }, /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.baseShade2
  }, totalVotes.toLocaleString(), " vote", `${totalVotes && totalVotes > 1 ? 's' : ''}`), /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.baseShade2
  }, "\u2022"), /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.baseShade2
  }, isPollClosed ? 'Ended' : `${(0, _time.formatTimeLeft)(poll.closedIn)} left`)), !isPollClosed && !isAlreadyVoted && !isAuthorSeeingResults && !isInReview && isAuthor && /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    onPress: () => setIsAuthorSeeingResults(true)
  }, /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "See results")), isAuthorSeeingResults && /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    onPress: () => setIsAuthorSeeingResults(false)
  }, /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "Back to vote")), !isPollClosed && isAlreadyVoted && !isAuthorSeeingResults && !disabledPoll && /*#__PURE__*/React.createElement(_reactNative.TouchableOpacity, {
    onPress: unvotePoll
  }, /*#__PURE__*/React.createElement(_Typography.Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "Unvote")));
}
//# sourceMappingURL=PollFooter.js.map