@using Moonlight.App.Database.Entities
@using Moonlight.App.Plugin.UI.Webspaces
@using Moonlight.App.Services
@using Moonlight.App.Services.Interop

@inject SmartTranslateService SmartTranslateService
@inject WebSpaceService WebSpaceService
@inject NavigationManager NavigationManager
@inject AlertService AlertService

<div class="card card-body">
    <div class="row">
        <div class="d-flex justify-content-between">
            <div class="d-flex">
                <div class="symbol symbol-circle me-5">
                    <div class="symbol-label bg-transparent text-primary border border-secondary border-dashed">
                        <i class="bx bx-globe bx-md"></i>
                    </div>
                </div>
                <div class="d-flex flex-column">
                    <div class="mb-1 fs-4">@(WebSpace.Domain)</div>
                    <div class="text-muted fs-5">@(WebSpace.CloudPanel.Name)</div>
                </div>
            </div>

            <WButton Text="@(SmartTranslateService.Translate("Delete"))"
                     WorkingText="@(SmartTranslateService.Translate("Deleting"))"
                     OnClick="Delete"
                     CssClasses="btn-danger">
            </WButton>
        </div>
    </div>
</div>
<div class="my-5"></div>
<div class="card mb-xl-10 mb-5">
    <div class="card-body pt-0 pb-0">
        <ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
            @foreach (var tab in Context.Tabs)
            {
                <li class="nav-item mt-2">
                    <a class="nav-link text-active-primary ms-0 me-10 py-5 @(Route == tab.Route ? "active" : "")" href="/webspace/@(WebSpace.Id + tab.Route)">
                        <TL>@(tab.Name)</TL>
                    </a>
                </li>
            }
        </ul>
    </div>
</div>

@code
{
    [Parameter]
    public string Route { get; set; }

    [Parameter]
    public WebSpace WebSpace { get; set; }
    
    [CascadingParameter]
    public WebspacePageContext Context { get; set; }

    private async Task Delete()
    {
        if (await AlertService.ConfirmMath())
        {
            await WebSpaceService.Delete(WebSpace);
            NavigationManager.NavigateTo("/webspaces");
        }
    }
}