Neighbourhood.omg.lol/Components/StatusList.razor

30 lines
880 B
Text

@inject IJSRuntime JS
@inject State State
@if (Editable) {
<EditStatusDialog @ref="Dialog" id="EditStatusModal"></EditStatusDialog>
}
@if(statuses != null) foreach(Status status in statuses) {
<StatusCard Status="@status" Editable="Editable" Dialog="Dialog"></StatusCard>
}
<LoadingCard id="statusLoading" icon="fa-solid fa-message-smile"></LoadingCard>
@code {
[Parameter]
public Func<Task<List<Status>?>> StatusFunc { get; set; }
[Parameter]
public bool Editable { get; set; } = false;
public EditStatusDialog? Dialog { get; set; }
private List<Status>? statuses;
protected override async Task OnInitializedAsync() {
await base.OnInitializedAsync();
if (statuses == null || statuses.Count == 0) statuses = await StatusFunc();
await InvokeAsync(StateHasChanged);
await JS.InvokeVoidAsync("removeElementById", "statusLoading");
}
}