<?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_<?= $block->escapeHtmlAttr($block->getTextType()) ?>'
">
    <div class="wtai-text-feedback-content wtai-content-<?= $block->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-<?= $block->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-<?= $block->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_<?= $block->escapeJs($block->getTextType()) ?>": {
                        "component": "WriteTextAI_WriteTextAI/js/edit/feedback",
                        "textType": "<?= $block->escapeJs($block->getTextType()) ?>",
                        "textLimit": "<?= $block->escapeJs($rules['maxFeedbackCharacters']) ?>",
                        "feedbackUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/feedback')) ?>",
                        "deleteFeedbackUrl": "<?= $block->escapeJs($block->getUrl('wtai/edit/feedback_delete')) ?>",
                        "entityType": "<?= $block->escapeJs($block->getEntityType()) ?>"
                    }
                }
            }
        }
    }
</script>
