<?php

// @codingStandardsIgnoreFile

/** @var \Aheadworks\Faq\Block\Article\Article $block */
?>
<?php
    $votesYes = $block->getArticle()->getVotesYes();
    $votesNo = $block->getArticle()->getVotesNo();
    if ($votesYes) {
        $ratingMessageNumber = __('%1%', ceil($votesYes / ($votesYes + $votesNo) * 100), ' ');
        $ratingMessage = __('of other people think it was helpful');
    } else {
        $ratingMessageNumber = '';
        $ratingMessage = __('Be the first to vote!');
    }
?>
    <input type="hidden" id="articleId" value="<?php echo (int)$block->getArticle()->getId() ?>">
    <?php if ( ($block->isAllowedHelpfulness()) > 0 ) : ?>
        <div id="aw-faq__helpfulness" class="cs-faq-index__voting-container">
            <span class="cs-faq-index__text cs-t-text cs-t-text--look_attention | <?php /* @noEscape */ echo $block->isVoted() ? '' : 'aw_bold'?>"><?php /* @noEscape */ echo __('Was this helpful?'); ?></span>
            <span id="aw__helpfulness-vote-yes" class="cs-faq-index__voting-icon | aw_bold <?php echo ($block->getDislikeStatus() || !$block->isVoted()) ? 'aw-no-display' : ''; ?>">
                <svg class="cs-faq-index__icon cs-faq-index__icon--checked">
                    <use xlink:href="#thumb_up"></use>
                </svg>
            </span>

            <span id="aw__helpfulness-vote-no" class="cs-faq-index__voting-icon | aw_bold <?php echo ($block->getLikeStatus() || !$block->isVoted()) ? 'aw-no-display' : ''; ?>">
                <svg class="cs-faq-index__icon cs-faq-index__icon--checked">
                    <use xlink:href="#thumb_down"></use>
                </svg>
            </span>
            <?php if ($block->isVoted() && $block->isHelpfulnessRateAfterVotingEnabled()): ?>
                <span class="cs-faq-index__rating-text">
                    <span class="cs-faq-index__text cs-t-text cs-t-text--look_attention" id="ratingMessage"><?php echo $block->escapeHtml($ratingMessageNumber); ?></span>
                    <span class="cs-faq-index__text cs-t-text"><?php echo $block->escapeHtml($ratingMessage); ?></span>
                </span>
            <?php endif;?>

            <?php if (!$block->isVoted()): ?>
                <span class="cs-faq-index__voting" id="aw__helpfulness-voting">

                    <a class="cs-faq-index__voting-icon" title="<?php echo $block->escapeHtml(__('I like it')); ?>" href="#" id="like">
                         <svg class="cs-faq-index__icon">
                            <use xlink:href="#thumb_up"></use>
                        </svg>
                    </a>
                    <span class="cs-faq-index__voting-separator"></span>
                    <a class="cs-faq-index__voting-icon" title="<?php echo $block->escapeHtml(__('I don\'t like it')); ?>" href="#" id="dislike">
                        <svg class="cs-faq-index__icon">
                            <use xlink:href="#thumb_down"></use>
                        </svg>
                    </a>
                </span>

                <span class="cs-faq-index__rating-text <?php echo $block->isHelpfulnessRateBeforeVotingEnabled() ? '' : 'aw-no-display'; ?>">
                    <span class="cs-faq-index__text cs-t-text cs-t-text--look_attention" id="ratingMessage"><?php echo $block->escapeHtml($ratingMessageNumber); ?></span>
                    <span class="cs-faq-index__text cs-t-text"><?php echo $block->escapeHtml($ratingMessage); ?></span>
                </span>
            <?php endif; ?>
        </div>
    <?php endif; ?>
<script type="text/x-magento-init">
{
    "#aw-faq__helpfulness": {
        "helpfulness" :  {"url":"<?php /* @noEscape */ echo $block->getUrl('faq/article/helpfulness'); ?>"}
    }
}
</script>