| | 1 | | @namespace Syki.Front.Pages.Cross |
| | 2 | |
|
| | 3 | | @page "/register" |
| | 4 | |
|
| | 5 | | <SykiPageTitle Title="Cadastro" /> |
| | 6 | |
|
| | 7 | | <MudContainer Class="mt-4 mb-8" MaxWidth="MaxWidth.ExtraSmall"> |
| | 8 | | <MudOverlay @bind-Visible="@_loading" LightBackground="true" Absolute="false"> |
| | 9 | | <MudProgressCircular Color="Color.Info" Indeterminate="true" Size="Size.Large" /> |
| | 10 | | </MudOverlay> |
| 0 | 11 | | <MudForm @ref="@_form"> |
| 0 | 12 | | <MudCard Class="px-4 pt-0 pb-4"> |
| 0 | 13 | | <MudImage Src="logo_512x512.png" Alt="Syki" Elevation="25" Class="rounded-lg mx-20 mt-10 mb-10"/> |
| 0 | 14 | | @if (_saved) |
| 0 | 15 | | { |
| 0 | 16 | | <MudAlert NoIcon="true" Class="mx-4 mb-4" Severity="Severity.Success" Variant="Variant.Text" ContentAlig |
| | 17 | | <MudText>Verifique seu email e utilize o link para definir sua senha de acesso.</MudText> |
| | 18 | | </MudAlert> |
| | 19 | | } |
| | 20 | | else |
| | 21 | | { |
| | 22 | | <AuthorizeView Policy="@FrontPolicy.SkipUserRegister"> |
| | 23 | | <MudButton |
| | 24 | | OnClick="@SkipUserRegister" |
| | 25 | | EndIcon="@Icons.Material.Filled.Login" |
| | 26 | | IconSize="Size.Medium" |
| | 27 | | Size="Size.Large" |
| | 28 | | Color="Color.Tertiary" |
| | 29 | | Variant="Variant.Filled" |
| | 30 | | Class="mx-auto mb-4 px-12 my-0" |
| | 31 | | > |
| | 32 | | Testar sem cadastro |
| | 33 | | </MudButton> |
| | 34 | | <MudStack Row="true" Spacing="0" AlignItems="AlignItems.Center" Justify="Justify.Center"> |
| | 35 | | <MudDivider DividerType="DividerType.FullWidth" Class="mt-2 mb-6" Style="width: 40%" /> |
| | 36 | | <MudIcon Icon="@Icons.Material.Filled.TripOrigin" Size="Size.Large" Class="mb-4" /> |
| | 37 | | <MudDivider DividerType="DividerType.FullWidth" Class="mt-2 mb-6" Style="width: 40%" /> |
| | 38 | | </MudStack> |
| | 39 | | </AuthorizeView> |
| | 40 | |
|
| | 41 | | <MudAlert NoIcon="true" Class="mx-4" Severity="Severity.Info" Variant="Variant.Text" ContentAlignment="H |
| | 42 | | <MudText Align="Align.Center">Cadastre seu email para ter acesso ao sistema.</MudText> |
| | 43 | | </MudAlert> |
| | 44 | | <MudCardContent Class="px-0 mx-4 pt-8 pb-0"> |
| | 45 | | <SykiTextField Label="Email" @bind-Value="@_email" /> |
| | 46 | | </MudCardContent> |
| | 47 | | <MudCardActions> |
| | 48 | | <MudButton |
| | 49 | | OnClick="@Submit" |
| | 50 | | Size="Size.Large" |
| | 51 | | Color="Color.Primary" |
| | 52 | | Variant="Variant.Filled" |
| | 53 | | Class="mx-auto mb-4 px-12 my-0" |
| | 54 | | > |
| | 55 | | Cadastrar |
| | 56 | | </MudButton> |
| | 57 | | </MudCardActions> |
| | 58 | | } |
| | 59 | | </MudCard> |
| | 60 | | </MudForm> |
| | 61 | | </MudContainer> |
| | 62 | |
|
| | 63 | | @inject ISnackbar Snackbar |
| | 64 | | @inject NavigationManager Nav |
| | 65 | | @inject HealthClient HealthClient |
| | 66 | | @inject SkipUserRegisterClient SkipUserRegisterClient |
| | 67 | | @inject CreatePendingUserRegisterClient CreatePendingUserRegisterClient |
| | 68 | |
|
| | 69 | | @code |
| | 70 | | { |
| | 71 | | private bool _saved; |
| | 72 | | private bool _loading; |
| | 73 | | private MudForm _form; |
| | 74 | | private string _email; |
| | 75 | |
|
| | 76 | | protected override async Task OnInitializedAsync() |
| | 77 | | { |
| 0 | 78 | | await HealthClient.Get(); |
| 0 | 79 | | } |
| | 80 | |
|
| | 81 | | private async Task SkipUserRegister() |
| | 82 | | { |
| 0 | 83 | | _loading = true; |
| 0 | 84 | | await SkipUserRegisterClient.Skip(); |
| 0 | 85 | | Nav.NavigateTo("/"); |
| 0 | 86 | | _loading = false; |
| 0 | 87 | | } |
| | 88 | |
|
| | 89 | | private async Task Submit() |
| | 90 | | { |
| 0 | 91 | | await _form.Validate(); |
| 0 | 92 | | if (!_form.IsValid) return; |
| | 93 | |
|
| 0 | 94 | | _loading = true; |
| 0 | 95 | | var response = await CreatePendingUserRegisterClient.Create(_email); |
| 0 | 96 | | if (response.IsSuccess()) |
| | 97 | | { |
| 0 | 98 | | _saved = true; |
| | 99 | | } |
| | 100 | | else |
| | 101 | | { |
| 0 | 102 | | Snackbar.Add(response.GetError().Message, Severity.Error); |
| | 103 | | } |
| 0 | 104 | | _loading = false; |
| 0 | 105 | | } |
| | 106 | | } |