import { useStyles } from './style';
import { TouchableOpacity, View } from 'react-native';
import { Typography } from '../../../core/components/Typography/Typography';
import { Client } from '@amityco/ts-sdk-react-native';
import { formatTimeLeft } from '../../../core/utils/time';
export function PollFooter({
  post,
  poll,
  totalVotes,
  isPollClosed,
  isAlreadyVoted,
  isAuthorSeeingResults,
  setIsAuthorSeeingResults,
  unvotePoll,
  disabledPoll
}) {
  var _post$creator;
  const {
    styles
  } = useStyles();
  const {
    userId
  } = 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(View, {
    style: styles.footer
  }, /*#__PURE__*/React.createElement(View, {
    style: styles.pollInfo
  }, /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.baseShade2
  }, totalVotes.toLocaleString(), " vote", `${totalVotes && totalVotes > 1 ? 's' : ''}`), /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.baseShade2
  }, "\u2022"), /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.baseShade2
  }, isPollClosed ? 'Ended' : `${formatTimeLeft(poll.closedIn)} left`)), !isPollClosed && !isAlreadyVoted && !isAuthorSeeingResults && !isInReview && isAuthor && /*#__PURE__*/React.createElement(TouchableOpacity, {
    onPress: () => setIsAuthorSeeingResults(true)
  }, /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "See results")), isAuthorSeeingResults && /*#__PURE__*/React.createElement(TouchableOpacity, {
    onPress: () => setIsAuthorSeeingResults(false)
  }, /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "Back to vote")), !isPollClosed && isAlreadyVoted && !isAuthorSeeingResults && !disabledPoll && /*#__PURE__*/React.createElement(TouchableOpacity, {
    onPress: unvotePoll
  }, /*#__PURE__*/React.createElement(Typography.CaptionBold, {
    style: styles.seeResultsBtnLabel
  }, "Unvote")));
}
//# sourceMappingURL=PollFooter.js.map