From 828034d0e22549a2cd765d6a0ac7d1b017dba692 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Tue, 6 Jan 2026 10:35:33 -0500 Subject: [PATCH] feat(client): migrate PartOperationFilterPanel to API clients --- .../PartOperationFilterPanel.razor | 40 ++++++++++++------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/NEW/src/JdeScoping.Client/Components/FilterPanels/PartOperationFilterPanel.razor b/NEW/src/JdeScoping.Client/Components/FilterPanels/PartOperationFilterPanel.razor index 55a14d7..3559672 100644 --- a/NEW/src/JdeScoping.Client/Components/FilterPanels/PartOperationFilterPanel.razor +++ b/NEW/src/JdeScoping.Client/Components/FilterPanels/PartOperationFilterPanel.razor @@ -1,5 +1,6 @@ @* Part operation/MIS filter panel with upload/download/clear functionality *@ -@inject IFileService FileService +@using JdeScoping.Core.ApiContracts +@inject IFileApiClient FileApi @inject DialogService DialogService @inject NotificationService NotificationService @@ -49,7 +50,15 @@ private async Task DownloadTemplateAsync() { - await FileService.DownloadTemplateAsync("partoperations", PartOperations); + var result = await FileApi.DownloadPartOperationsTemplateAsync(PartOperations.AsReadOnly()); + result.Switch( + bytes => { _ = JSRuntime.InvokeVoidAsync("downloadFile", "partoperations_template.xlsx", bytes); }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Template not found."); }, + validation => { NotificationService.Notify(NotificationSeverity.Error, "Error", string.Join("; ", validation.FieldErrors.SelectMany(e => e.Value))); }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Session expired."); }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Access denied."); }, + error => { NotificationService.Notify(NotificationSeverity.Error, "Error", error.Message); } + ); } private async Task TriggerFileInput() @@ -65,19 +74,22 @@ try { using var stream = e.File.OpenReadStream(maxAllowedSize: 10 * 1024 * 1024); // 10MB max - var result = await FileService.UploadAsync("partoperations", stream, e.File.Name); + var result = await FileApi.UploadPartOperationsAsync(stream, e.File.Name); - if (result.WasSuccessful) - { - PartOperations.Clear(); - PartOperations.AddRange(result.Data); - await PartOperationsChanged.InvokeAsync(PartOperations); - NotificationService.Notify(NotificationSeverity.Success, "Upload Complete", $"Loaded {result.Data.Count} part operations."); - } - else - { - NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", result.ErrorMessage); - } + result.Switch( + partOperations => + { + PartOperations.Clear(); + PartOperations.AddRange(partOperations); + _ = PartOperationsChanged.InvokeAsync(PartOperations); + NotificationService.Notify(NotificationSeverity.Success, "Upload Complete", $"Loaded {partOperations.Count} part operations."); + }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Upload endpoint not found."); }, + validation => { NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", string.Join("; ", validation.FieldErrors.SelectMany(e => e.Value))); }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Session expired."); }, + _ => { NotificationService.Notify(NotificationSeverity.Error, "Error", "Access denied."); }, + error => { NotificationService.Notify(NotificationSeverity.Error, "Upload Failed", error.Message); } + ); } catch (Exception ex) {