@using BTCPayServer.Services.Apps
@model ListAppsViewModel
@{
    ViewData["Title"] = "Apps";
}

<section>
    <div class="container">

        <div class="row">
            <div class="col-lg-12 text-center">
                <partial name="_StatusMessage" for="@TempData["TempDataProperty-StatusMessage"]" />
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12 text-center">
                <h2 class="section-heading">@ViewData["Title"]</h2>
                <hr class="primary">
                <p>Create and manage apps.</p>
            </div>
        </div>

        <div class="row no-gutter" style="margin-bottom: 5px;">
            <div class="col-lg-6">
                <a asp-action="CreateApp" class="btn btn-primary" role="button" id="CreateNewApp"><span class="fa fa-plus"></span> Create a new app</a>
                <a href="https://docs.btcpayserver.org/features/apps" target="_blank"><span class="fa fa-question-circle-o" title="More information..."></span></a>
            </div>
        </div>
        <div class="row">
            <table class="table table-sm table-responsive-md">
                <thead>
                    <tr>
                        <th>Store</th>
                        <th>Name</th>
                        <th>App type</th>
                        <th style="text-align:right">Actions</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach (var app in Model.Apps)
                    {
                        <tr>
                            <td>
                                @if (app.IsOwner)
                                {
                                    <span><a asp-action="UpdateStore" asp-controller="Stores" asp-route-storeId="@app.StoreId">@app.StoreName</a></span>
                                }
                                else
                                {
                                    <span>@app.StoreName</span>
                                }
                            </td>
                            <td>@app.AppName</td>
                            <td>@app.AppType</td>
                            <td style="text-align:right">
                                @if (app.IsOwner)
                                {
                                    <a asp-action="@app.UpdateAction" asp-controller="Apps" asp-route-appId="@app.Id">Settings</a><span> - </span>
                                }
                                <a asp-action="@app.ViewAction" asp-controller="AppsPublic" asp-route-appId="@app.Id">View</a><span> - </span>
                                <a asp-action="DeleteApp" asp-route-appId="@app.Id">Remove</a>
                            </td>
                        </tr>
                    }
                </tbody>
            </table>
        </div>
    </div>
</section>
