@model BTCPayServer.Models.ServerViewModels.RatesViewModel
@{
    ViewData.SetActivePageAndTitle(ServerNavPages.Rates);
}


<partial name="_StatusMessage" />


<div class="row">
    <div class="col-md-6">
        <div asp-validation-summary="All" class="text-danger"></div>
    </div>
</div>
<div class="row">
    <div class="col-md-8">
        <div class="form-group">
            <h5>Bitcoin Average</h5>
            <p>BTCPay relies on Bitcoin Average for getting crypto-currency to fiat rates</p>
            <p>If you want BTCPay rate cache to be smaller than 15min, you should register to BitcoinAverage and get a paid API Key.</p>
            <p>If your BTCPay server instance supports lot's of merchant or is used a lot, BitcoinAverage will rate limit your server, and invoice will be created using less accurate rates. (From Bitpay)<br /></p>
        </div>
        <form method="post">
            <label asp-for="PublicKey"></label>
            <div class="form-inline">
                <input asp-for="PublicKey" style="width:50%;" class="form-control" placeholder="Public key" />
                <label class="sr-only" asp-for="PrivateKey"></label>
                <input asp-for="PrivateKey" style="width:50%;" class="form-control" placeholder="Private key" />
                <p class="form-text text-muted">You can find the information on <a target="_blank" href="https://bitcoinaverage.com/en/apikeys">bitcoinaverage api key page</a></p>
            </div>
            <div class="form-group">
                <label asp-for="CacheMinutes"></label>
                <input asp-for="CacheMinutes" class="form-control" />
                <span asp-validation-for="CacheMinutes" class="text-danger"></span>
            </div>
            @if(Model.RateLimits != null)
            {
                <h5>Current Bitcoin Average Quotas:</h5>
                <table class="table table-sm removetopborder">
                    <tr>
                        <th>Quota period</th>
                        <td>@Model.RateLimits.TotalPeriod.TimeString()</td>
                    </tr>
                    <tr>
                        <th>Requests quota</th>
                        <td>@Model.RateLimits.RequestsLeft/@Model.RateLimits.RequestsPerPeriod</td>
                    </tr>
                    <tr>
                        <th>Quota reset in</th>
                        <td>@Model.RateLimits.CounterReset.TimeString()</td>
                    </tr>
                </table>
            }
            <button type="submit" class="btn btn-primary" name="command" value="Save">Save</button>
        </form>
    </div>
</div>

@section Scripts {
    @await Html.PartialAsync("_ValidationScriptsPartial")
}
