117 lines
No EOL
3.7 KiB
Text
117 lines
No EOL
3.7 KiB
Text
@page "/accountedit"
|
|
@using Lieb.Data
|
|
@using Lieb.Models
|
|
@using Lieb.Models.GuildWars2
|
|
@using System.ComponentModel.DataAnnotations
|
|
@using System.Security.Claims
|
|
@inject UserService UserService
|
|
@inject NavigationManager NavigationManager
|
|
@inject AuthenticationStateProvider AuthenticationStateProvider
|
|
@inject IJSRuntime JsRuntime
|
|
|
|
<h3>Manage Account</h3>
|
|
|
|
<AuthorizeView Context="authorizationContext">
|
|
<Authorized>
|
|
<EditForm Model="@_user" OnValidSubmit="@HandleValidSubmit">
|
|
<DataAnnotationsValidator />
|
|
|
|
<p>@_saveMessage</p>
|
|
<p>
|
|
<label>
|
|
Name:
|
|
<InputText @bind-Value="_user.Name" />
|
|
</label>
|
|
</p>
|
|
<p>
|
|
<input type="checkbox" @bind="_user.AlwaysSignUpWithMainAccount" /> Always sign up with main account
|
|
</p>
|
|
<p>
|
|
<input type="checkbox" @bind="_user.ReminderSubscription" /> Get Raid Reminders
|
|
</p>
|
|
@*<p>
|
|
<label>
|
|
Pronouns:
|
|
<InputText @bind-Value="_user.Pronouns" />
|
|
</label>
|
|
</p>*@
|
|
|
|
@*<p>
|
|
<label>
|
|
Birthday:
|
|
<InputDate @bind-Value="_user.Birthday" />
|
|
</label>
|
|
</p>*@
|
|
|
|
<br />
|
|
<div class="nav-item px-3">
|
|
<NavLink class="nav-link" href="gw2accountedit">
|
|
<span class="oi oi-plus" aria-hidden="true"></span> Add Guild Wars 2 Account
|
|
</NavLink>
|
|
</div>
|
|
<table>
|
|
<tr>
|
|
<th>Main Account</th>
|
|
<th>Edit</th>
|
|
</tr>
|
|
<InputRadioGroup @bind-Value="_user.MainGW2Account">
|
|
@foreach(GuildWars2Account account in _user.GuildWars2Accounts)
|
|
{
|
|
<tr>
|
|
<td>
|
|
<InputRadio Value="@account.GuildWars2AccountId" /> @account.AccountName
|
|
</td>
|
|
<td>
|
|
<div class="nav-item px-3">
|
|
@{string navLink = $"gw2accountedit/{@account.GuildWars2AccountId}";}
|
|
<NavLink class="nav-link" href="@navLink">Edit</NavLink>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
}
|
|
</InputRadioGroup>
|
|
</table>
|
|
|
|
<br />
|
|
<button type="submit">Save</button>
|
|
<ValidationSummary />
|
|
</EditForm>
|
|
<button type="delete" @onclick="() => DeleteAccountClicked()">Delete Account</button>
|
|
</Authorized>
|
|
</AuthorizeView>
|
|
|
|
|
|
@code {
|
|
|
|
public LiebUser _user;
|
|
private string _saveMessage = string.Empty;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
var authState = await AuthenticationStateProvider.GetAuthenticationStateAsync();
|
|
|
|
ulong discordId = ulong.Parse(authState.User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.NameIdentifier).Value);
|
|
_user = UserService.GetLiebUserGW2AccountOnly(discordId);
|
|
}
|
|
|
|
async Task Changed(int buildId, ChangeEventArgs args)
|
|
{
|
|
bool canTank = bool.Parse(args.Value.ToString());
|
|
}
|
|
|
|
private async Task HandleValidSubmit()
|
|
{
|
|
await UserService.EditUser(_user);
|
|
_saveMessage = "changes saved successfully";
|
|
}
|
|
|
|
async Task DeleteAccountClicked()
|
|
{
|
|
bool confirmed = await JsRuntime.InvokeAsync<bool>("confirm", "Are you sure you want to delete this Website Account?\nThis will sign you off in every raid in which you are signed up.");
|
|
if (confirmed)
|
|
{
|
|
NavigationManager.NavigateTo("Account/Logout", true);
|
|
await UserService.DeleteUser(_user.Id);
|
|
}
|
|
}
|
|
} |