@using Microsoft.AspNetCore.Http.Features

@{
    var consentFeature = Context.Features.Get<ITrackingConsentFeature>();
    var showBanner = !consentFeature?.CanTrack ?? false;
    var cookieString = consentFeature?.CreateConsentCookie();
}

@if (showBanner)
{
    <div id="cookieConsent" class="navbar navbar-default navbar-fixed-top" role="alert">
        <div class="container">
            <div class="row">
                <div class="col-1 h-100 mt-1 text-right pr-0">
                    <span>
                        <i class="ft-alert-circle font-large-1" aria-hidden="true"></i>
                    </span>
                </div>
                <div class="col-11">
                    <div class="row">
                        <div class="col-12 font-medium-1 mt-1">
                            Cookies help us deliver our services. By using our services you agree to our use of cookies.
                        </div>
                        <div class="col-12">
                            <a asp-controller="Home" asp-action="Privacy" class="btn btn-info navbar-btn">Learn More</a>
                            <button type="button" class="btn btn-primary navbar-btn" data-cookie-string="@cookieString">Accept</button>
                        </div>
                    </div>
                    
                </div>                
            </div>
        </div>
    </div>
    <script>
        (function () {
            document.querySelector("#cookieConsent button[data-cookie-string]").addEventListener("click", function (el) {
                document.cookie = el.target.dataset.cookieString;
                document.querySelector("#cookieConsent").classList.add("hidden");
            }, false);
        })();
    </script>
}