@page "/suppliers" @inject SupplierService SupplierService @inject NavigationManager Navigation Suppliers

Suppliers

Add Supplier
@if (loading) {

Loading...

} else if (suppliers.Count == 0) {
No suppliers found. Add your first supplier.
} else { @foreach (var supplier in suppliers) { }
Name Contact Info Notes Actions
@supplier.Name @supplier.ContactInfo @TruncateText(supplier.Notes, 50) Edit
} @code { private List suppliers = new(); private bool loading = true; private ConfirmDialog deleteDialog = null!; private Supplier? supplierToDelete; private string deleteMessage = ""; protected override async Task OnInitializedAsync() { suppliers = await SupplierService.GetAllAsync(); loading = false; } private void ConfirmDelete(Supplier supplier) { supplierToDelete = supplier; deleteMessage = $"Are you sure you want to delete \"{supplier.Name}\"? This will also remove all stock lengths associated with this supplier."; deleteDialog.Show(); } private async Task DeleteConfirmed() { if (supplierToDelete != null) { await SupplierService.DeleteAsync(supplierToDelete.Id); suppliers = await SupplierService.GetAllAsync(); } } private string? TruncateText(string? text, int maxLength) { if (string.IsNullOrEmpty(text) || text.Length <= maxLength) return text; return text.Substring(0, maxLength) + "..."; } }