< Summary - Syki

Information
Class: Syki.Front.Features.Cross.SetupMfa.SetupMfaInput
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Cross/SetupMfa/SetupMfaInput.razor
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 20
Coverable lines: 20
Total lines: 97
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 10
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
HandleCodeChanged()0%4260%
OpenDialog()100%210%

File(s)

/home/runner/work/syki/syki/Front/Features/Cross/SetupMfa/SetupMfaInput.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Cross.SetupMfa
 2
 3<MudPaper Style="position: relative; height: 100%">
 4    <MudOverlay @bind-Visible="@_validateCodeLoading" LightBackground="true" Absolute="true">
 5        <MudProgressCircular Color="Color.Info" Indeterminate="true" Size="Size.Large" />
 6    </MudOverlay>
 7
 8    <MudCard Class="px-4 py-0" Elevation="0" Style="height: 100%">
 9        <MudCardContent>
 10            <MudStack AlignItems="AlignItems.Center">
 11                <MudAlert NoIcon="true" Severity="Severity.Info" Variant="Variant.Text">
 12                    <MudStack Row="true" Justify="Justify.SpaceAround">
 13                        <MudText>Insira o código gerado pelo app para finalizar o setup</MudText>
 14                    </MudStack>
 15                </MudAlert>
 16                <MudForm>
 17                    <style>
 18                        .align-center input {
 19                            text-align: center;
 20                        }
 21                    </style>
 22                    <MudNumericField
 23                        data-testid="mfa-code-input"
 24                        T="int?"
 25                        Immediate="true"
 26                        OnlyValidateIfDirty="true"
 27                        ReadOnly="@_validateCodeLoading"
 28                        Disabled="@_codeIsCorrect"
 29                        Style="width: 200px;"
 30                        Value="@_userCode"
 31                        ValueChanged="@HandleCodeChanged"
 32                        Variant="Variant.Outlined"
 33                        HideSpinButtons="true"
 34                        Typo="Typo.h6"
 35                        Class="mt-8"
 36                        Margin="Margin.Dense"
 37                        Max="999999"
 38                        MaxLength="6"
 39                        Min="0"
 40                    />
 41                </MudForm>
 42
 043                @if (_showCodeFeedback && !_codeIsCorrect)
 44                {
 45                    <MudAlert Class="mt-2" Severity="Severity.Error" Variant="Variant.Text">
 46                        <MudStack Row="true" Justify="Justify.SpaceAround">
 47                            <MudText>Código inválido</MudText>
 48                        </MudStack>
 49                    </MudAlert>
 50                }
 51            </MudStack>
 52        </MudCardContent>
 53    </MudCard>
 54</MudPaper>
 55
 56@inject SetupMfaClient Client
 57@inject IDialogService DialogService
 58@inject IBrowserViewportService BrowserViewportService
 59
 60@code
 61{
 62    private int? _userCode;
 63    private bool _validateCodeLoading;
 64    private bool _showCodeFeedback;
 65    private bool _codeIsCorrect;
 66
 67    private async Task HandleCodeChanged(int? newValue)
 68    {
 069        _showCodeFeedback = false;
 070        _userCode = newValue;
 71
 072        if (_userCode != null && _userCode.ToString().Length == 6)
 73        {
 074            _validateCodeLoading = true;
 075            _codeIsCorrect = await Client.Setup(_userCode.ToString()!);
 076            _showCodeFeedback = true;
 077            _validateCodeLoading = false;
 78        }
 79
 080        if (_codeIsCorrect)
 81        {
 082            await OpenDialog();
 83        }
 084    }
 85
 86    private async Task OpenDialog()
 87    {
 088        var breakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
 089        var options = new DialogOptions {
 090            FullWidth = true,
 091            CloseButton = false,
 092            MaxWidth = MaxWidth.ExtraSmall,
 093            FullScreen = breakpoint == Breakpoint.Xs,
 094        };
 095        await DialogService.ShowAsync<SetupMfaDialog>("", options);
 096    }
 97}

Methods/Properties

HandleCodeChanged()
OpenDialog()