@using BTCPayServer
@using BTCPayServer.Models.StoreViewModels
@using BTCPayServer.Plugins.Breez
@using BTCPayServer.Security
@using BTCPayServer.Services.Invoices
@using Microsoft.AspNetCore.Mvc.TagHelpers
@inject BreezService BreezService
@inject PaymentMethodHandlerDictionary PaymentMethodHandlerDictionary
@{
    Layout = "_Layout";
    ViewData.SetActivePage("Breez", "Sweep", "Sweep");
    string storeId = null;
    if (Model is string s)
    {
        storeId = s;
    }
    else if (Model is StoreDashboardViewModel dashboardModel)
    {
        storeId = dashboardModel.StoreId;
    }
    else
    {
        storeId = Context.GetImplicitStoreId();
    }
    var sdk = BreezService.GetClient(storeId)?.Sdk;
    if (sdk is null)
        return;
    var deriv = Context.GetStoreData().GetDerivationSchemeSettings(PaymentMethodHandlerDictionary, "BTC");
    var f = sdk.RecommendedFees();
}
<datalist id="fees">
    <option value="@f.fastestFee">Fastest fee (@f.fastestFee sat/vB)</option>
    <option value="@f.halfHourFee">Half hour fee (@f.halfHourFee sat/vB)</option>
    <option value="@f.hourFee">Hour fee (@f.hourFee sat/vB)</option>
    <option value="@f.economyFee">Economic fee (@f.economyFee sat/vB)</option>
    <option value="@f.minimumFee">Minimum fee (@f.minimumFee sat/vB)</option>
</datalist>
<datalist list="addresses">
    @if (deriv is not null)
    {
    <option value="store"> Store wallet</option>
    }
</datalist>
<form method="post" asp-action="Sweep" asp-route-storeId="@storeId">
    <div class="row mb-4">
        <div class="col-12">
            <div class="d-flex align-items-center justify-content-between mb-3">
                <h3 class="mb-0">
                    <span>@ViewData["Title"]</span>
                </h3>
                <div class="d-flex gap-3 mt-3 mt-sm-0">

                    <button type="submit" class="btn btn-primary">Create</button>
                </div>
            </div>
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>

            <div class="form-group">
                <label for="address" class="form-label" data-required>Address</label>
                <input type="text" id="address" list="addresses" name="address" class="form-control" required/>
            </div>
            <div class="form-group">
                <label for="satPerByte" class="form-label" data-required>Feerate</label>
                <input type="number" min="@f.minimumFee" list="fees" id="satPerByte" name="satPerByte" class="form-control" required/>
            </div>

        </div>
    </div>
</form>