Added tag/creator status update functionality on the API and UI layers.
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
@page "/creators"
|
||||
@inject VoiceWorksClient Client
|
||||
@inject IJSRuntime JS
|
||||
@using AntDesign
|
||||
@using JSMR.Application.Common.Search
|
||||
@using JSMR.Application.Creators.Commands.UpdateCreatorStatus
|
||||
@using JSMR.Application.Creators.Contracts
|
||||
@using JSMR.Application.Creators.Queries.Search
|
||||
@using JSMR.Application.Creators.Queries.Search.Contracts
|
||||
@using JSMR.UI.Blazor.Components
|
||||
@@ -50,20 +53,29 @@
|
||||
<AntDesign.Tag Color="AntDesign.TagColor.RedInverse">Blacklisted</AntDesign.Tag>
|
||||
}
|
||||
</AntDesign.PropertyColumn>
|
||||
@* <AntDesign.ActionColumn HeaderStyle="width: 2em">
|
||||
<AntDesign.Dropdown Trigger="@(new AntDesign.Trigger[] { AntDesign.Trigger.Click })">
|
||||
<Overlay>
|
||||
<AntDesign.Menu>
|
||||
<AntDesign.MenuItem>
|
||||
<span>Some Menu Item</span>
|
||||
</AntDesign.MenuItem>
|
||||
</AntDesign.Menu>
|
||||
</Overlay>
|
||||
<ChildContent>
|
||||
<AntDesign.Button Shape="AntDesign.ButtonShape.Circle" Icon="@AntDesign.IconType.Outline.More" Type="AntDesign.ButtonType.Default"></AntDesign.Button>
|
||||
</ChildContent>
|
||||
</AntDesign.Dropdown>
|
||||
</AntDesign.ActionColumn> *@
|
||||
<AntDesign.ActionColumn HeaderStyle="width: 5em;" Style="text-align: center">
|
||||
<Dropdown Trigger="@([Trigger.Click])">
|
||||
<Overlay>
|
||||
<Menu Selectable="false">
|
||||
@if (!context.Favorite)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, CreatorStatus.Favorite)">Set as Favorite</MenuItem>
|
||||
}
|
||||
@if (!context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, CreatorStatus.Blacklisted)">Set as Blacklisted</MenuItem>
|
||||
}
|
||||
@if (context.Favorite || context.Blacklisted)
|
||||
{
|
||||
<MenuItem OnClick="(e) => SetStatus(context, CreatorStatus.Neutral)">Set as Neutral</MenuItem>
|
||||
}
|
||||
</Menu>
|
||||
</Overlay>
|
||||
<ChildContent>
|
||||
<Button Icon="Ellipsis"></Button>
|
||||
</ChildContent>
|
||||
</Dropdown>
|
||||
</AntDesign.ActionColumn>
|
||||
</ColumnDefinitions>
|
||||
</AntDesign.Table>
|
||||
<JPagination2 PageNumber="PageNumber" PageNumberChanged="OnPageNumberChanged" PageSize="PageSize" PageSizeChanged="OnPageSizeChanged" TotalItems="TotalItems" />
|
||||
@@ -119,6 +131,9 @@
|
||||
[Inject]
|
||||
protected NavigationManager NavigationManager { get; set; } = default!;
|
||||
|
||||
[Inject]
|
||||
INotificationService NotificationService { get; set; } = default!;
|
||||
|
||||
public string? Keywords { get; set; }
|
||||
public int PageNumber { get; set; } = 1;
|
||||
public int PageSize { get; set; } = 100;
|
||||
@@ -259,4 +274,31 @@
|
||||
|
||||
NavigationManager.NavigateTo(uri);
|
||||
}
|
||||
|
||||
private async Task SetStatus(CreatorSearchItem item, CreatorStatus status)
|
||||
{
|
||||
UpdateCreatorStatusRequest request = new(
|
||||
CreatorId: item.CreatorId,
|
||||
CreatorStatus: status
|
||||
);
|
||||
|
||||
UpdateCreatorStatusResponse? response = await Client.UpdateCreatorStatusAsync(request);
|
||||
|
||||
if (response is not null)
|
||||
{
|
||||
item.Favorite = response.CreatorStatus is CreatorStatus.Favorite;
|
||||
item.Blacklisted = response.CreatorStatus is CreatorStatus.Blacklisted;
|
||||
}
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
var config = new NotificationConfig()
|
||||
{
|
||||
Message = $"Creator Status Update",
|
||||
Description = $"Creator '{item.Name}' set to {status.ToString()}.",
|
||||
Placement = NotificationPlacement.Top
|
||||
};
|
||||
|
||||
await NotificationService.Open(config);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user