<?php
/**
 * Webkul Software.
 *
 * @category  Webkul
 * @package   Webkul_Marketplace
 * @author    Webkul
 * @copyright Copyright (c) Webkul Software Private Limited (https://webkul.com)
 * @license   https://store.webkul.com/license.html
 */
?>
<!-- set data in js window variable, used in navigation.js file -->
<script>
    window.notificationConfig = <?= /* @escapeNotVerified */ \Zend_Json::encode($block->getNotificationConfig()); ?>;
</script>
<!-- include js file defined in default.xml -->
<div id="notification-component" data-bind="scope:'notification-content'" class="field">
    <script type="text/x-magento-init">
    {
        "#notification-component": {
            "Magento_Ui/js/core/app":  <?= /* @escapeNotVerified */ $block->getJsLayout();?>
        }
    }
    </script>
</div>
<!-- notification template called in navigation.js file -->
<script id="wk_notification_template" type="text/x-magento-template">
    <div class="wk-notification-block">
        <a href="" class="wk-notifications-action marketplace-dropdown">
        <img class="wk-notification-img" height="20" width="20" src="<%- data.notificationImage %>" />
        <% if (data.notificationCount > 5) { %>
            <span class="wk-notification-count">5+</span>
        <% } else { %>
            <span class="wk-notification-count"><%- data.notificationCount %></span>
        <% } %>
        </a>
        <ul class="marketplace-dropdown-menu">
        <span class="notify-point"></span>
            <% count = 1 %>
            <% _.each(data.notifications, function(i) { %>
                <% if (count <= 5) { %>
                <li class="wk-notifications-entry">
                    <strong class="wk-notifications-entry-title">
                        <?= "<%= i.title %>"; ?>
                    </strong>
                    <p class="wk-notifications-entry-description _cutted">
                        <a href="<%- i.url %>" class="wk-notifications-entry-description-start">
                            <span>
                                <%= i.desc %>
                            </span>
                        </a>
                    </p>
                    <time class="wk-notifications-entry-time">
                        <%- i.updated_time %>
                    </time>
                </li>
                <% count++ %>
                <% } %>
            <%  }); %>
        <% if (count > 5) { %>
            <% if (data.notificationType == 'product') { %>
            <li class="wk-notifications-entry notifications-entry-last" style="background: #403934">
                <a href="<?= $block->escapeUrl($block->getUrl('marketplace/product/index')); ?>">
                    <?= $block->escapeHtml(__('Click here to view product(s) list')); ?>
                </a>
            </li>
            <%  } %>
            <% if (data.notificationType == 'seller') { %>
            <li class="wk-notifications-entry notifications-entry-last" style="background: #403934">
                <a href="<?= $block->escapeUrl($block->getUrl('marketplace/seller/index')); ?>">
                    <?= $block->escapeHtml(__('Click here to view seller(s) list')); ?>
                </a>
            </li>
            <%  } %>
            <% if (data.notificationType == 'feedback') { %>
            <li class="wk-notifications-entry notifications-entry-last" style="background: #403934">
                <a href="<?= $block->escapeUrl($block->getUrl('marketplace/feedback/index')); ?>">
                    <?= $block->escapeHtml(__('Click here to view feedback(s) list')); ?>
                </a>
            </li>
            <%  } %>
        <%  } %>
        </ul>
    </div>
</script>
