< Summary

Information
Class: Syki.Front.Features.Academic.CreateNotification.CreateNotificationDialog
Assembly: Front
File(s): /home/runner/work/syki/syki/Front/Features/Academic/CreateNotification/CreateNotificationDialog.razor
Tag: 22_11348620282
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 84
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 8
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_MudDialog()100%210%
Submit()0%4260%
Cancel()100%210%

File(s)

/home/runner/work/syki/syki/Front/Features/Academic/CreateNotification/CreateNotificationDialog.razor

#LineLine coverage
 1@namespace Syki.Front.Features.Academic.CreateNotification
 2
 3<MudDialog Class="pb-2">
 4    <TitleContent>
 5        <MudText Typo="Typo.h6">
 6            <MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1 mb-n1" />
 7            Nova Notificação
 8        </MudText>
 9    </TitleContent>
 10    <DialogContent>
 011        <MudForm @ref="@_form" Class="pt-1">
 012            <SykiTextField Label="Título" AutoFocus="true" @bind-Value="@_title" />
 013            <SykiTextField Label="Descrição" @bind-Value="@_description" />
 014            <MudSelect
 015                Dense="true"
 016                Margin="Margin.Dense"
 17                Variant="Variant.Outlined"
 18                Class="mb-4"
 19                @bind-Value="@_targetUsers"
 20                Label="Usuários"
 21                Required="true"
 22                RequiredError="Informe!"
 23                AdornmentColor="Color.Primary"
 24            >
 025                @foreach (UsersGroup? item in Enum.GetValues<UsersGroup>())
 26                {
 27                    <MudSelectItem Value="@item">@item.GetDescription()</MudSelectItem>
 28                }
 29            </MudSelect>
 30            <MudStack Row="true" AlignItems="AlignItems.Center" Spacing="1" Class="pl-0">
 31                <MudCheckBox @bind-Value="@_timeless" Label="Notificar novos usuários?" Color="Color.Primary" />
 32                <MudTooltip Text="Se marcado, usuários criados após a notificação também irão recebê-la." Arrow="true" P
 33                    <MudIconButton Icon="@Icons.Material.Filled.Info" Size="Size.Small" />
 34                </MudTooltip>
 35            </MudStack>
 36        </MudForm>
 37    </DialogContent>
 38    <DialogActions>
 39        <DialogCancelButton OnClick="@Cancel" />
 40        <SykiProgressCircular Loading="@_loading" />
 41        <DialogSaveButton OnClick="@Submit" />
 42    </DialogActions>
 43</MudDialog>
 44
 45@inject ISnackbar Snackbar
 46@inject CreateNotificationClient Client
 47
 48@code
 49{
 50    [CascadingParameter]
 051    MudDialogInstance MudDialog { get; set; }
 52
 53    private MudForm _form;
 54    private bool _loading;
 55
 56    private string _title;
 57    private string _description;
 58    private UsersGroup? _targetUsers;
 59    private bool _timeless;
 60
 61    private async Task Submit()
 62    {
 063        if (_loading) return;
 64
 065        await _form.Validate();
 066        if (!_form.IsValid) return;
 67
 068        _loading = true;
 069        var response = await Client.Create(_title, _description, _targetUsers!.Value, _timeless);
 070        if (response.IsSuccessStatusCode)
 71        {
 072            MudDialog.Close(DialogResult.Ok(true));
 073            Snackbar.Add("Notificação cadastrada com sucesso!", Severity.Success);
 74        }
 75        else
 76        {
 077            var error = await response.ToError();
 078            Snackbar.Add(error.Message, Severity.Error);
 79        }
 080        _loading = false;
 081    }
 82
 083    private void Cancel() => MudDialog.Cancel();
 84}

Methods/Properties

get_MudDialog()
Submit()
Cancel()