| | 1 | | @using Syki.Front.Components.Indexes |
| | 2 | |
|
| | 3 | | @namespace Syki.Front.Features.Teacher.GetTeacherInsights |
| | 4 | |
|
| | 5 | | <MudContainer Class="my-4 px-4"> |
| | 6 | | <MudText Typo="Typo.h4" Style="font-weight: bold" Class="ml-2"> |
| | 7 | | Olá, @_userName |
| | 8 | | </MudText> |
| | 9 | | <MudAlert Class="mt-4" NoIcon="true" Severity="Severity.Normal" Variant="Variant.Text" Elevation="1"> |
| | 10 | | <MudStack Row="true" Justify="Justify.SpaceAround"> |
| | 11 | | <MudText>Aqui você encontra dados consolidados sobre suas turmas.</MudText> |
| | 12 | | </MudStack> |
| | 13 | | </MudAlert> |
| | 14 | | <MudGrid Class="pt-4" Spacing="4"> |
| | 15 | | <IndexCard Loading="@_loading" Icon="@Icons.Material.Filled.CheckCircle" Value="@_data.Classes" Text="Turmas" /> |
| | 16 | | <IndexCard Loading="@_loading" Icon="@Icons.Material.Filled.School" Value="@_data.Students" Text="Alunos" /> |
| | 17 | | <TeacherInsightCard Loading="@_loading" Icon="@Icons.Material.Filled.Class" Text="@GetLessonsMessage()" /> |
| | 18 | | </MudGrid> |
| | 19 | | </MudContainer> |
| | 20 | |
|
| | 21 | | @inject GetTeacherInsightsClient Client |
| | 22 | |
|
| | 23 | | @code |
| | 24 | | { |
| | 25 | | [CascadingParameter] |
| 0 | 26 | | public Task<AuthenticationState> AuthState { get; set; } |
| | 27 | |
|
| | 28 | | private bool _loading; |
| 0 | 29 | | private string _userName = ""; |
| 0 | 30 | | private TeacherInsightsOut _data = new(); |
| | 31 | |
|
| | 32 | | protected override async Task OnInitializedAsync() |
| | 33 | | { |
| 0 | 34 | | _loading = true; |
| 0 | 35 | | await SetUserName(); |
| 0 | 36 | | _data = await Client.Get(); |
| 0 | 37 | | _loading = false; |
| 0 | 38 | | } |
| | 39 | |
|
| | 40 | | private string GetLessonsMessage() |
| | 41 | | { |
| 0 | 42 | | return $"{_data.FinalizedLessons}/{_data.TotalLessons} Aulas"; |
| | 43 | | } |
| | 44 | |
|
| | 45 | | private async Task SetUserName() |
| | 46 | | { |
| 0 | 47 | | var state = await AuthState; |
| | 48 | |
|
| 0 | 49 | | var claim = state.User.FindFirst("name"); |
| 0 | 50 | | if (claim != null) |
| | 51 | | { |
| 0 | 52 | | _userName = claim.Value; |
| | 53 | | } |
| 0 | 54 | | } |
| | 55 | | } |