@using Shared.DTOs
@using Front.Services
@inject HttpClientController hc;
@inject Fixedvalues fv;
<Modal @ref="cusmodal" />
<div class="col-md-5 col-lg-3 order-2 mb-4">
    <div class="card h-100">
        <div class="card-header d-flex align-items-center justify-content-between">
            <h5 class="card-title m-0 me-2">فاکتور برای مشتری</h5>
            <span class="badge bg-label-warning rounded-pill">هفنه گدشته</span>
        </div>
        <div class="card-body">
            <ul class="p-0 m-0">
                @foreach (var item in model)
                {
                    <li class="d-flex">
                        <div class="d-flex w-100 flex-wrap align-items-center justify-content-between gap-2">
                            <div class="me-2">

                                <button @onclick="()=>CustomerItem(item.ID)" type="button" class="btn btn-link">@item.Title</button>
             
                            </div>
                            <div class="user-progress d-flex align-items-center gap-1"><h6 class="mb-0">@item.count.Value.ToString("N0")</h6> <span class="text-muted">عدد</span></div>
                        </div>
                    </li>
                }
         
            </ul>
        </div>
    </div>
</div>

@code {
    [Parameter] public List<IdNameByCount<int>>? model { get; set; }
    private Modal cusmodal = default!;
}
@functions{
    public async Task CallBackCustomerItem(ActionInResultComponent result)
    {

    }
    public async Task CustomerItem(int ID)
    {
        var rsp = await hc.Get($"Customer/GetCustomer/{ID}");
        if (rsp.IsSuccessStatusCode)
        {
            var cus = await rsp.Content.ReadFromJsonAsync<RCustomer>();
            var parameters = new Dictionary<string, object>();
            parameters.Add("Cus", cus);
            parameters.Add("OnMultipleOfThree", EventCallback.Factory.Create<ActionInResultComponent>(this, CallBackCustomerItem));
            await cusmodal.ShowAsync<CUSComponent.CustomerItem>(title: "ویرایش اطلاعات", parameters: parameters);
        }
    }
}

