@model TokensViewModel
@{
    Layout = "../Shared/_NavLayout.cshtml";
    ViewData.SetActivePageAndTitle(StoreNavPages.Tokens, "Access Tokens");
}

<partial name="_StatusMessage" for="StatusMessage" />
@if (Model.StoreNotConfigured)
{
    <div class="alert alert-warning alert-dismissible" role="alert">
        <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <span>Warning: No wallet has been linked to your BTCPay Store. See <a href="https://docs.btcpayserver.org/btcpay-basics/gettingstarted#connecting-btcpay-store-to-your-wallet" target="_blank">this link</a> for more information on how to connect your store and wallet.</span>
    </div>
}
<h4>Access token</h4>
<div class="row">
    <div class="col-md-8">
        <p>Authorize a public key to access Bitpay compatible Invoice API (<a href="https://support.bitpay.com/hc/en-us/articles/115003001183-How-do-I-pair-my-client-and-create-a-token-">More information</a>)</p>
    </div>
</div>
<div class="row">
    <div class="col-md-8">
        <a asp-action="CreateToken" class="btn btn-primary" role="button"><span class="fa fa-plus"></span> Create a new token</a>
        <table class="table table-sm table-responsive-md">
            <thead>
                <tr>
                    <th>Label</th>
                    <th class="text-right">Actions</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var token in Model.Tokens)
                {
                    <tr>
                        <td>@token.Label</td>
                        <td class="text-right">
                            <a asp-action="ShowToken" asp-route-tokenId="@token.Id">See information</a> - <a asp-action="RevokeToken" asp-route-tokenId="@token.Id">Revoke</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>

<h4>Legacy API Keys</h4>
<div class="row">
    <div class="col-md-8">
        <p>Alternatively, you can use the invoice API by including the following HTTP Header in your requests:<br /> <code>Authorization: Basic @Model.EncodedApiKey</code> </p>
    </div>
</div>

<div class="row">
    <div class="col-md-8">
        <form method="post" asp-action="GenerateAPIKey">
            <div class="form-group">
                <label asp-for="ApiKey"></label>
                <input asp-for="ApiKey" readonly class="form-control" />
            </div>
            <button type="submit" class="btn btn-primary" role="button">Create new API Key</button>
        </form>
    </div>
</div>
