65 lines
1.7 KiB
Plaintext
65 lines
1.7 KiB
Plaintext
@using Moonlight.Shared.Http.Requests.Users
|
|
@using ShadcnBlazor.Dialogs
|
|
@using ShadcnBlazor.Extras.Forms
|
|
@using ShadcnBlazor.Fields
|
|
@using ShadcnBlazor.Inputs
|
|
|
|
@inherits ShadcnBlazor.Extras.Dialogs.DialogBase
|
|
|
|
<DialogHeader>
|
|
<DialogTitle>
|
|
Create new user
|
|
</DialogTitle>
|
|
<DialogDescription>
|
|
Create a new user by giving it a username and an email address
|
|
</DialogDescription>
|
|
</DialogHeader>
|
|
|
|
<EnhancedEditForm Model="Request" OnValidSubmit="OnSubmitAsync">
|
|
|
|
<FieldGroup>
|
|
<FormValidationSummary/>
|
|
<DataAnnotationsValidator/>
|
|
|
|
<FieldSet>
|
|
<Field>
|
|
<FieldLabel for="username">Username</FieldLabel>
|
|
<TextInputField
|
|
@bind-Value="Request.Username"
|
|
id="username"
|
|
placeholder="Name of the user"/>
|
|
</Field>
|
|
<Field>
|
|
<FieldLabel for="emailAddress">Email Address</FieldLabel>
|
|
<TextInputField
|
|
@bind-Value="Request.Email"
|
|
id="emailAddress"
|
|
placeholder="email@of.user"/>
|
|
</Field>
|
|
</FieldSet>
|
|
<Field Orientation="FieldOrientation.Horizontal" ClassName="justify-end">
|
|
<SubmitButton>Save changes</SubmitButton>
|
|
</Field>
|
|
</FieldGroup>
|
|
</EnhancedEditForm>
|
|
|
|
@code
|
|
{
|
|
[Parameter] public Func<CreateUserDto, Task> OnSubmit { get; set; }
|
|
|
|
private CreateUserDto Request;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
Request = new();
|
|
}
|
|
|
|
private async Task<bool> OnSubmitAsync(EditContext editContext, ValidationMessageStore validationMessageStore)
|
|
{
|
|
await OnSubmit.Invoke(Request);
|
|
await CloseAsync();
|
|
|
|
return true;
|
|
}
|
|
}
|