<?php
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
?>

<?php
/** @var \WriteTextAI\WriteTextAI\ViewModel\Settings $settings */
$settings = $block->getSettings();
$rules = $settings->getSettings('rules');
?>

<div class="wtai-text-feedback" data-bind="
    scope: 'wtaiTextFeedback_<?= $escaper->escapeHtmlAttr($block->getTextType()) ?>'
">
    <div class="wtai-text-feedback-content wtai-content-<?= $escaper->escapeHtmlAttr($block->getTextType()) ?>"
    >
        <button class="wtai-like wtai-active"
            data-bind="
                click: like,
                visible: isLiked,
                css : { 'wtai-liked': isLiked }
            "
        ></button>
        <button class="wtai-like wtai-dropdown-button-<?= $escaper->escapeHtmlAttr($block->getTextType()) ?>"
            data-bind="
                click: like,
                hidden: isLiked,
                css : { 'wtai-liked': isLiked }
            "
        ></button>
        <button class="wtai-dislike wtai-active"
            data-bind="
                click: dislike,
                visible: isDisliked,
                css : { 'wtai-disliked': isDisliked }
            "
        ></button>
        <button class="wtai-dislike wtai-dropdown-button-<?= $escaper->escapeHtmlAttr($block->getTextType()) ?>"
            data-bind="
                click: dislike,
                hidden: isDisliked,
                css : { 'wtai-disliked': isDisliked }
            "
        ></button>
    </div>
</div>
<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "wtaiTextFeedback_<?= $escaper->escapeJs($block->getTextType()) ?>": {
                        "component": "WriteTextAI_WriteTextAI/js/edit/feedback",
                        "textType": "<?= $escaper->escapeJs($block->getTextType()) ?>",
                        "textLimit": "<?= $escaper->escapeJs($rules['maxFeedbackCharacters']) ?>",
                        "feedbackUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/feedback')) ?>",
                        "deleteFeedbackUrl": "<?= $escaper->escapeJs($block->getUrl('wtai/edit/feedback_delete')) ?>",
                        "entityType": "<?= $escaper->escapeJs($block->getEntityType()) ?>"
                    }
                }
            }
        }
    }
</script>
