| | | 1 | | @* CharacterClaimButton.razor - Refactored to accept data as parameters *@ |
| | | 2 | | @* Pure presentation component - no service dependencies *@ |
| | | 3 | | |
| | 9 | 4 | | @if (IsLoading) |
| | | 5 | | { |
| | | 6 | | <MudProgressCircular Size="Size.Small" Indeterminate="true" /> |
| | | 7 | | } |
| | 8 | 8 | | else if (ClaimStatus != null) |
| | | 9 | | { |
| | 8 | 10 | | @if (ClaimStatus.IsClaimedByMe) |
| | | 11 | | { |
| | | 12 | | <MudButton Variant="Variant.Outlined" |
| | | 13 | | Color="Color.Success" |
| | | 14 | | Size="Size.Small" |
| | | 15 | | StartIcon="@Icons.Material.Filled.CheckCircle" |
| | | 16 | | OnClick="HandleUnclaim" |
| | | 17 | | Disabled="IsProcessing"> |
| | 3 | 18 | | @if (IsProcessing) |
| | | 19 | | { |
| | | 20 | | <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" /> |
| | | 21 | | } |
| | | 22 | | My Character |
| | | 23 | | </MudButton> |
| | | 24 | | } |
| | 5 | 25 | | else if (ClaimStatus.IsClaimed) |
| | | 26 | | { |
| | | 27 | | <MudTooltip Text="@($"Claimed by {ClaimStatus.ClaimedByName}")"> |
| | | 28 | | <MudChip T="string" |
| | | 29 | | Size="Size.Small" |
| | | 30 | | Variant="Variant.Outlined" |
| | | 31 | | Icon="@Icons.Material.Filled.Person"> |
| | 0 | 32 | | @ClaimStatus.ClaimedByName's Character |
| | | 33 | | </MudChip> |
| | | 34 | | </MudTooltip> |
| | | 35 | | } |
| | | 36 | | else |
| | | 37 | | { |
| | | 38 | | <MudButton Variant="Variant.Outlined" |
| | | 39 | | Color="Color.Primary" |
| | | 40 | | Size="Size.Small" |
| | | 41 | | StartIcon="@Icons.Material.Filled.PersonAdd" |
| | | 42 | | OnClick="HandleClaim" |
| | | 43 | | Disabled="IsProcessing"> |
| | 5 | 44 | | @if (IsProcessing) |
| | | 45 | | { |
| | | 46 | | <MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" /> |
| | | 47 | | } |
| | | 48 | | Claim as My Character |
| | | 49 | | </MudButton> |
| | | 50 | | } |
| | | 51 | | } |
| | | 52 | | |
| | | 53 | | @code { |
| | | 54 | | /// <summary> |
| | | 55 | | /// The character's claim status data. |
| | | 56 | | /// Parent component is responsible for loading this data. |
| | | 57 | | /// </summary> |
| | | 58 | | [Parameter] |
| | 27 | 59 | | public CharacterClaimStatusDto? ClaimStatus { get; set; } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Whether data is currently being loaded. |
| | | 63 | | /// Controls the loading indicator display. |
| | | 64 | | /// </summary> |
| | | 65 | | [Parameter] |
| | 16 | 66 | | public bool IsLoading { get; set; } |
| | | 67 | | |
| | | 68 | | /// <summary> |
| | | 69 | | /// Whether a claim/unclaim operation is in progress. |
| | | 70 | | /// Controls button disabled state and processing indicator. |
| | | 71 | | /// </summary> |
| | | 72 | | [Parameter] |
| | 18 | 73 | | public bool IsProcessing { get; set; } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// Event raised when the user requests to claim the character. |
| | | 77 | | /// Parent component handles the actual API call. |
| | | 78 | | /// </summary> |
| | | 79 | | [Parameter] |
| | 2 | 80 | | public EventCallback OnClaim { get; set; } |
| | | 81 | | |
| | | 82 | | /// <summary> |
| | | 83 | | /// Event raised when the user requests to unclaim the character. |
| | | 84 | | /// Parent component handles the actual API call. |
| | | 85 | | /// </summary> |
| | | 86 | | [Parameter] |
| | 2 | 87 | | public EventCallback OnUnclaim { get; set; } |
| | | 88 | | |
| | | 89 | | private async Task HandleClaim() |
| | | 90 | | { |
| | 1 | 91 | | await OnClaim.InvokeAsync(); |
| | 1 | 92 | | } |
| | | 93 | | |
| | | 94 | | private async Task HandleUnclaim() |
| | | 95 | | { |
| | 1 | 96 | | await OnUnclaim.InvokeAsync(); |
| | 1 | 97 | | } |
| | | 98 | | |
| | | 99 | | // Note: CharacterClaimStatusDto is defined in Chronicis.Api\Controllers\CharactersController.cs |
| | | 100 | | // This is a temporary location - ideally should be moved to Chronicis.Shared.DTOs |
| | | 101 | | } |