< Summary

Information
Class: Syki.Front.Pages.Cross.RegisterSetupPage
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Pages/Cross/RegisterSetupPage.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 94
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Token()100%210%
.ctor()100%210%
HandlePasswordChange(...)100%210%
GoToLogin()100%210%
Submit()0%620%

File(s)

/home/runner/work/syki/syki/Front/Pages/Cross/RegisterSetupPage.razor

#LineLine coverage
 1@using Syki.Front.Components.Passwords
 2
 3@namespace Syki.Front.Pages.Cross
 4
 5@page "/register-setup"
 6
 7<SykiPageTitle Title="Cadastro" />
 8
 9<MudContainer Class="mt-4 mb-8" MaxWidth="MaxWidth.ExtraSmall">
 10    <MudOverlay @bind-Visible="@_loading" LightBackground="true" Absolute="false">
 11        <MudProgressCircular Color="Color.Info" Indeterminate="true" Size="Size.Large" />
 12    </MudOverlay>
 13    <MudForm>
 14        <MudCard Class="px-4 pt-0 pb-4">
 15            <MudImage Src="logo_512x512.png" Alt="Syki" Elevation="25" Class="rounded-lg mx-20 mt-10 mb-10"/>
 016            @if (_saved)
 17            {
 18                <MudStack AlignItems="AlignItems.Center">
 19                    <MudAlert NoIcon="true" Class="mt-6 mb-6" Severity="Severity.Success" Variant="Variant.Text" Content
 20                        <MudText>Pronto, agora é só logar!</MudText>
 21                    </MudAlert>
 22                    <MudButton
 23                        Size="Size.Large"
 24                        OnClick="@GoToLogin"
 25                        Variant="Variant.Filled"
 26                        Color="Color.Primary"
 27                        Class="my-4 px-12">
 28                        Ir pro login
 29                    </MudButton>
 30                </MudStack>
 31            }
 32            else
 33            {
 34                <MudCardContent Class="pt-0 pb-2 px-0">
 35                    <PasswordTextField Value="@_setup.Password" ValueChanged="@HandlePasswordChange" Class="pb-2 px-4" R
 36                    <PasswordRequerimentsCard @bind-Validation="@_setup.Validation"/>
 37                </MudCardContent>
 38                <MudCardActions>
 39                    <MudButton
 40                        Size="Size.Large"
 41                        OnClick="@Submit"
 42                        Disabled="@(!_setup.IsValid())"
 43                        Variant="Variant.Filled"
 44                        Color="Color.Primary"
 45                        Class="mx-auto mb-4 px-12">
 46                        SALVAR
 47                    </MudButton>
 48                </MudCardActions>
 49            }
 50        </MudCard>
 51    </MudForm>
 52</MudContainer>
 53
 54@inject ISnackbar Snackbar
 55@inject NavigationManager Nav
 56@inject FinishUserRegisterClient Client
 57
 58@code
 59{
 60    [Parameter]
 61    [SupplyParameterFromQuery]
 062    public string? Token { get; set; }
 63
 64    private bool _saved;
 65    private bool _loading;
 066    private SetupPassword _setup = new();
 67
 68    private void HandlePasswordChange(string newValue)
 69    {
 070        _setup.Password = newValue;
 071        _setup.Validate();
 072    }
 73
 74    private void GoToLogin()
 75    {
 076        Nav.NavigateTo("/login");
 077    }
 78
 79    private async Task Submit()
 80    {
 081        _loading = true;
 082        var response = await Client.Finish(Token, _setup.Password);
 083        if (response.IsSuccessStatusCode)
 84        {
 085            _saved = true;
 86        }
 87        else
 88        {
 089            var error = await response.ToError();
 090            Snackbar.Add(error.Message, Severity.Error);
 91        }
 092        _loading = false;
 093    }
 94}