Skip to content

Commit 96e1ce5

Browse files
feat: Remove AddOrUpdateCustomerDialog component and integrate customer creation in Quotations
- Deleted the AddOrUpdateCustomerDialog component to streamline the codebase. - Enhanced the AddOrUpdateQuotation component to include a button for creating new customers directly from the quotations page, improving user experience. - Implemented a dialog for customer creation, allowing for immediate updates to the customer list upon successful addition.
1 parent 1931b25 commit 96e1ce5

File tree

2 files changed

+56
-15
lines changed

2 files changed

+56
-15
lines changed

src/WebApps/TunNetCom.SilkRoadErp.Sales.WebApp/Components/Pages/Quotations/AddOrUpdateQuotation.razor

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,30 @@ else
7676
<RadzenDatePicker @bind-Value="quotationDate" Name="QuotationDate" Style="width: 200px;" DateFormat="d MMMM yyyy" ShowTime="false" />
7777

7878
<RadzenLabel Text="@Localizer["customer"]" />
79-
<RadzenDropDownDataGrid AllowClear="true"
80-
IsLoading="@isLoadingCustomers"
81-
@bind-Value="@selectedCustomerId"
82-
LoadData="@LoadCustomers"
83-
AllowFiltering="true"
84-
Style="width: 350px;"
85-
Data="@_filteredCustomers"
86-
TextProperty="@nameof(CustomerResponse.Name)"
87-
ValueProperty="@nameof(CustomerResponse.Id)"
88-
Placeholder="@Localizer["select_customer"]">
89-
<Columns>
90-
<RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Id)" Title="ID" Width="80px" />
91-
<RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Name)" Title="@Localizer["name"]" Width="220px" />
92-
</Columns>
93-
</RadzenDropDownDataGrid>
79+
<RadzenStack Orientation="Radzen.Orientation.Horizontal" Gap="0.5rem" AlignItems="Radzen.AlignItems.Center">
80+
<RadzenDropDownDataGrid AllowClear="true"
81+
IsLoading="@isLoadingCustomers"
82+
@bind-Value="@selectedCustomerId"
83+
LoadData="@LoadCustomers"
84+
AllowFiltering="true"
85+
Style="width: 350px;"
86+
Data="@_filteredCustomers"
87+
TextProperty="@nameof(CustomerResponse.Name)"
88+
ValueProperty="@nameof(CustomerResponse.Id)"
89+
Placeholder="@Localizer["select_customer"]">
90+
<Columns>
91+
<RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Id)" Title="ID" Width="80px" />
92+
<RadzenDropDownDataGridColumn Property="@nameof(CustomerResponse.Name)" Title="@Localizer["name"]" Width="220px" />
93+
</Columns>
94+
</RadzenDropDownDataGrid>
95+
<RadzenButton Icon="add"
96+
ButtonStyle="ButtonStyle.Success"
97+
Variant="Variant.Flat"
98+
Size="ButtonSize.Medium"
99+
Click="@CreateNewCustomer"
100+
Title="@Localizer["AddClient"]"
101+
AriaLabel="@Localizer["AddClient"]" />
102+
</RadzenStack>
94103

95104
@if (!string.IsNullOrEmpty(quotationNumber))
96105
{
@@ -564,6 +573,38 @@ else
564573
await InvokeAsync(StateHasChanged);
565574
}
566575

576+
async Task CreateNewCustomer()
577+
{
578+
var result = await DialogService.OpenAsync<AddOrUpdateCustomerDialog>(
579+
Localizer["AddClient"],
580+
new Dictionary<string, object>(),
581+
new DialogOptions
582+
{
583+
Width = "600px",
584+
Resizable = true,
585+
Draggable = true
586+
});
587+
588+
if (result is int newCustomerId)
589+
{
590+
await LoadCustomers(new LoadDataArgs());
591+
selectedCustomerId = newCustomerId;
592+
593+
var customer = await customersApiClient.GetCustomerByIdAsync(newCustomerId, _cancellationTokenSource.Token);
594+
if (customer != null && !_filteredCustomers.Any(c => c.Id == customer.Id))
595+
{
596+
_filteredCustomers.Add(customer);
597+
}
598+
599+
NotificationService.Notify(new NotificationMessage
600+
{
601+
Severity = NotificationSeverity.Success,
602+
Summary = Localizer["success"],
603+
Detail = $"{Localizer["customer"]} {Localizer["created_with_success"]}"
604+
});
605+
}
606+
}
607+
567608
async Task OnProductSelectedHandler(QuotationDetailResponse order)
568609
{
569610
UpdateTotals();

src/WebApps/TunNetCom.SilkRoadErp.Sales.WebApp/Components/Pages/DeliveryNotes/AddOrUpdateCustomerDialog.razor renamed to src/WebApps/TunNetCom.SilkRoadErp.Sales.WebApp/Components/Shared/AddOrUpdateCustomerDialog.razor

File renamed without changes.

0 commit comments

Comments
 (0)