@namespace Oqtane.Themes.Controls @inherits ThemeControlBase @inject ICookieConsentService CookieConsentService @inject IJSRuntime JSRuntime @inject IStringLocalizer Localizer @if (showBanner) {
@if (ChildContent != null) { @ChildContent } else { @((MarkupString)Convert.ToString(Localizer["ConsentBody"])) }
} @code { private bool showBanner; [Parameter] public RenderFragment ChildContent { get; set; } = null; protected override async Task OnInitializedAsync() { showBanner = !(await CookieConsentService.CanTrackAsync()); } private async Task AcceptPolicy() { var cookieString = await CookieConsentService.CreateConsentCookieAsync(); if (!string.IsNullOrEmpty(cookieString)) { var interop = new Interop(JSRuntime); await interop.SetCookieString(cookieString); showBanner = false; } } }