| | 1 | | @namespace Syki.Front.Features.Academic.UpdateEnrollmentPeriod |
| | 2 | |
|
| | 3 | | <MudDialog Class="pb-2" Style="min-height: 450px"> |
| | 4 | | <TitleContent> |
| | 5 | | <MudText Typo="Typo.h6"> |
| | 6 | | <MudIcon Icon="@Icons.Material.Outlined.Edit" Class="mr-1 mb-n1" /> |
| | 7 | | Editar Período de Matrícula |
| | 8 | | </MudText> |
| | 9 | | </TitleContent> |
| | 10 | | <DialogContent> |
| 0 | 11 | | <MudForm @ref="@_form" Class="py-1"> |
| 0 | 12 | | <MudGrid Spacing="2"> |
| 0 | 13 | | <MudFlexBreak /> |
| 0 | 14 | | <MudItem xs="12"> |
| 0 | 15 | | <SykiDatePicker Label="Início" @bind-Date="@_start"/> |
| 0 | 16 | | </MudItem> |
| | 17 | | <MudItem xs="12"> |
| | 18 | | <SykiDatePicker Label="Fim" @bind-Date="@_end"/> |
| | 19 | | </MudItem> |
| | 20 | | </MudGrid> |
| | 21 | | </MudForm> |
| | 22 | | </DialogContent> |
| | 23 | | <DialogActions> |
| | 24 | | <DialogCancelButton OnClick="@Cancel" /> |
| | 25 | | <SykiProgressCircular Loading="@_loading" /> |
| | 26 | | <DialogSaveButton OnClick="@Submit" /> |
| | 27 | | </DialogActions> |
| | 28 | | </MudDialog> |
| | 29 | |
|
| | 30 | | @inject ISnackbar Snackbar |
| | 31 | | @inject UpdateEnrollmentPeriodClient Client |
| | 32 | |
|
| | 33 | | @code |
| | 34 | | { |
| | 35 | | [CascadingParameter] |
| 0 | 36 | | MudDialogInstance MudDialog { get; set; } |
| | 37 | |
|
| | 38 | | [Parameter] |
| 0 | 39 | | public EnrollmentPeriodOut Period { get; set; } |
| | 40 | |
|
| | 41 | | private MudForm _form; |
| | 42 | | private bool _loading; |
| | 43 | |
|
| | 44 | | private DateTime? _start; |
| | 45 | | private DateTime? _end; |
| | 46 | |
|
| | 47 | | protected override void OnInitialized() |
| | 48 | | { |
| 0 | 49 | | base.OnInitialized(); |
| 0 | 50 | | _start = Period.StartAt.ToDateTime(); |
| 0 | 51 | | _end = Period.EndAt.ToDateTime(); |
| 0 | 52 | | } |
| | 53 | |
|
| | 54 | | async Task Submit() |
| | 55 | | { |
| 0 | 56 | | if (_loading) return; |
| | 57 | |
|
| 0 | 58 | | await _form.Validate(); |
| 0 | 59 | | if (!_form.IsValid) return; |
| | 60 | |
|
| 0 | 61 | | var start = DateOnly.FromDateTime(_start!.Value); |
| 0 | 62 | | var end = DateOnly.FromDateTime(_end!.Value); |
| | 63 | |
|
| 0 | 64 | | _loading = true; |
| 0 | 65 | | var response = await Client.Update(Period.Id, start, end); |
| 0 | 66 | | if (response.IsSuccess()) |
| | 67 | | { |
| 0 | 68 | | MudDialog.Close(DialogResult.Ok(true)); |
| 0 | 69 | | Snackbar.Add("Período editado com sucesso!", Severity.Success); |
| | 70 | | } |
| | 71 | | else |
| | 72 | | { |
| 0 | 73 | | Snackbar.Add(response.GetError().Message, Severity.Error); |
| | 74 | | } |
| 0 | 75 | | _loading = false; |
| 0 | 76 | | } |
| | 77 | |
|
| 0 | 78 | | void Cancel() => MudDialog.Cancel(); |
| | 79 | | } |