Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminsampica committed Dec 25, 2021
2 parents 3594026 + 4bad0b1 commit e1785ae
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 5 deletions.
8 changes: 7 additions & 1 deletion DynamoLeagueBlazor/Client/Features/Fines/List.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ public partial class List : IDisposable
private readonly CancellationTokenSource _cts = new();

protected override async Task OnInitializedAsync()
{
await LoadDataAsync();
}

private async Task LoadDataAsync()
{
try
{
Expand All @@ -44,7 +49,8 @@ private void OpenManageFineDialog(int fineId)
{
var parameters = new DialogParameters
{
{ nameof(Manage.FineId), fineId }
{ nameof(Manage.FineId), fineId },
{ nameof(Manage.OnManageButtonClick), EventCallback.Factory.Create(this, () => LoadDataAsync())}
};

DialogService.Show<Manage>("Manage Fine", parameters);
Expand Down
9 changes: 7 additions & 2 deletions DynamoLeagueBlazor/Client/Features/Fines/Manage.razor
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<DialogActions>
<MudGrid Spacing=1>
<MudItem xs=12>
<MudButton Color="Color.Error" Variant=Variant.Text StartIcon=@Icons.Outlined.Delete ButtonType=ButtonType.Submit Disabled="@_processingForm" FullWidth=true Size=Size.Large>
<MudButton Color="Color.Error" Variant=Variant.Text StartIcon=@Icons.Outlined.Delete
ButtonType=ButtonType.Submit Disabled="@_processingForm" FullWidth=true
Size=Size.Large OnClick="@(() => IsApproved(false))">
@if (_processingForm)
{
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
Expand All @@ -20,7 +22,10 @@
</MudButton>
</MudItem>
<MudItem xs=12>
<MudButton Color="Color.Success" Variant=Variant.Text StartIcon=@Icons.Outlined.Check ButtonType=ButtonType.Submit Disabled="@_processingForm" FullWidth=true Size=Size.Large>
<MudButton
Color="Color.Success" Variant=Variant.Text StartIcon=@Icons.Outlined.Check
ButtonType=ButtonType.Submit Disabled="@_processingForm" FullWidth=true
Size=Size.Large OnClick="@(() => IsApproved(true))">
@if (_processingForm)
{
<MudProgressCircular Class="ms-n1" Size="Size.Small" Indeterminate="true"/>
Expand Down
7 changes: 6 additions & 1 deletion DynamoLeagueBlazor/Client/Features/Fines/Manage.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public partial class Manage : IDisposable
[Inject] private ISnackbar SnackBar { get; set; } = null!;
[CascadingParameter] MudDialogInstance MudDialogInstance { get; set; } = null!;
[Parameter, EditorRequired] public int FineId { get; set; }
[Parameter, EditorRequired] public EventCallback OnManageButtonClick { get; set; }

private ManageFineRequest _form = null!;
private bool _processingForm;
Expand All @@ -33,6 +34,7 @@ private async Task OnValidSubmitAsync()
if (response.IsSuccessStatusCode)
{
SnackBar.Add("Successfully updated fine.", Severity.Success);
await OnManageButtonClick.InvokeAsync();
}
else
{
Expand All @@ -48,7 +50,10 @@ private async Task OnValidSubmitAsync()
MudDialogInstance.Close();
}

private void Cancel() => MudDialogInstance.Close();
private void IsApproved(bool approved)
{
_form.Approved = approved;
}

public void Dispose()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private async Task OnValidSubmitAsync()

if (response.IsSuccessStatusCode)
{
SnackBar.Add("Successfully added fine.", Severity.Success);
SnackBar.Add("Successfully added a fine. An administrator will either approve or deny the fine.", Severity.Success);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions DynamoLeagueBlazor/Server/Features/Fines/List.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public async Task<FineListResult> Handle(ListQuery request, CancellationToken ca
{
var fines = await _dbContext.Fines
.Include(p => p.Player)
.OrderBy(f => f.Status)
.ProjectTo<FineListResult.FineItem>(_mapper.ConfigurationProvider)
.ToListAsync(cancellationToken);

Expand Down

0 comments on commit e1785ae

Please sign in to comment.