@using Grand.Domain.Customers
@inject StoreInformationSettings storeInformationSettings
@inject IWorkContext workContext

@if (storeInformationSettings.DisplayCookieInformation && !workContext.CurrentCustomer.IsSystemAccount)
{
    if (workContext.CurrentCustomer.GetUserFieldFromEntity<bool>(SystemCustomerFieldNames.CookieAccepted, workContext.CurrentStore.Id))
        return;

    if (TempData["Grand.IgnoreCookieInformation"] != null && Convert.ToBoolean(TempData["Grand.IgnoreCookieInformation"]))
        return;

    <script asp-location="Footer" asp-order="300">
            document.addEventListener("DOMContentLoaded", function () {
                document.getElementById('cookie-bar-notification').style.display = "block";
            });
            function cookieFnc(e) {
                var postData = {
                    accept: e.getAttribute("data-accept")
                };
                axios({
                    method: 'post',
                    url: '@Url.RouteUrl("CookieAccept")',
                    params: postData,
                }).then(function (response) {
                    document.getElementById('cookie-bar-notification').style.display = "none";
                }).catch(function (error) {
                    alert(error);
                })
            }
    </script>

    <div id="cookie-bar-notification" class="cookie-bar-notification" style="display:none;">
        <div class="card alert alert-info mx-3">
            <div class="d-inline-flex justify-content-center align-items-center flex-sm-nowrap flex-wrap w-100 mb-0">
                <p class="mb-0">@Loc["Cookie.Description2"]</p>
                <div class="btn-group-sm ml-0 mx-sm-3 mt-sm-0 mt-2">
                    <button class="btn btn-outline-secondary cookielaw-button" id="cookie-ok" onclick="cookieFnc(this)" data-accept="true">@Loc["Cookie.Accept"]</button>
                    <button class="btn btn-outline-secondary cookielaw-button mx-1" id="cookie-refuse" onclick="cookieFnc(this)" data-accept="false">@Loc["Cookie.Refuse"]</button>
                    <a class="btn btn-info learn-more" href="@Url.RouteUrl("Page", new { SeName = PageSeNameConstants.Privacyinfo })">@Loc["Cookie.LearnMore"]</a>
                </div>
            </div>
        </div>
    </div>
}


