@using BTCPayServer.Client
@using Microsoft.AspNetCore.Mvc.TagHelpers
@using BTCPayServer.Views.Apps
@using BTCPayServer.Services.Apps
@using BTCPayServer
@using BTCPayServer.Abstractions.Extensions
@using BTCPayServer.Plugins.TicketTailor
@inject AppService AppService;
@model BTCPayServer.Components.MainNav.MainNavViewModel
@{
    var store = Context.GetStoreData();
}

@if (store != null)
{
    var appType = AppService.GetAppType(TicketTailorApp.AppType)!;
    <li class="nav-item" permission="@Policies.CanModifyStoreSettings">
        <a asp-area="" asp-controller="UIApps" asp-action="CreateApp" asp-route-storeId="@store.Id" asp-route-appType="@appType.Type" class="nav-link @ViewData.IsActivePage(AppsNavPages.Create, appType.Type)" id="@($"StoreNav-Create{appType.Type}")">
            <img style="width:14px; margin-right: 10px;" class="icon" src="~/Resources/assets/tt.png" />
            <span>@appType.Description</span>
        </a>
    </li>
    @foreach (var app in Model.Apps.Where(app => app.AppType == appType.Type))
    {
        <li class="nav-item nav-item-sub" permission="@Policies.CanModifyStoreSettings">
            <a asp-area="" asp-controller="TicketTailor" asp-action="UpdateTicketTailorSettings" asp-route-appId="@app.Id" class="nav-link @ViewData.IsActivePage(AppsNavPages.Update, app.Id)" id="@($"StoreNav-App-{app.Id}")">
                <span>@app.AppName</span>
            </a>
        </li>
        <li class="nav-item nav-item-sub" not-permission="@Policies.CanModifyStoreSettings">
            <a asp-area="" asp-controller="TicketTailor" asp-action="View" asp-route-appId="@app.Id" class="nav-link">
                <span>@app.AppName</span>
            </a>
        </li>
    }
}