GuestLog - Improvements to GuestDocument creation

- Added DocumentNumber validations.
- Added new page to see GuestDocument details.
This commit is contained in:
2026-07-30 20:31:13 +02:00
parent 5061f9362b
commit a5eea09eee
13 changed files with 465 additions and 42 deletions
@@ -0,0 +1,81 @@
@attribute [Route($"{GuestConsts.Page_GuestDocs_Detail}")]
@using Somnia.GuestLog.Models.DTOs;
@using Somnia.GuestLog.Services;
@inject ISnackbar Snackbar
@inject IDialogService DialogService
@inject NavigationManager Navigation
@inject IGuestDocumentService guestDocService
@inject FluentValidation.IValidator<GuestDocIdDTO> docIdValidator;
<PageTitle>Somnia - Guest Docs - Details</PageTitle>
<MudStack Row="true" Class="my-4">
<MudText Typo="Typo.h4" GutterBottom="true">Guest Document - "@docId"</MudText>
<MudSpacer />
<MudButton Variant="Variant.Filled" Color="Color.Success" Size="Size.Small" StartIcon="@Icons.Material.Filled.Add"
OnClick="() => BtnEdit()">
@LanguageLocale.general_btnEdit
</MudButton>
<MudButton Variant="Variant.Filled" Color="Color.Default" Size="Size.Small"
StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="() => BtnReturn()">
@LanguageLocale.general_btnReturn
</MudButton>
</MudStack>
@if (documentModel is not null)
{
<GuestDocForm @ref="_form" Model="documentModel" ReadOnly="true" />
}
@code {
[Parameter]
public string? docId { get; set; }
GuestDocForm _form = null!;
GuestDocumentDTO? documentModel = null;
protected override async Task OnInitializedAsync()
{
if (docId is null)
{
Snackbar.Add("No GuestDocument provided!!", Severity.Error);
Navigation.NotFound();
return;
}
GuestDocIdDTO? docIdModel = GuestDocIdDTO.DecodeFromString(docId);
if (docIdModel is null)
{
Snackbar.Add($"Provided GuestDocId can't be decoded: '{docId}'", Severity.Error);
Navigation.NotFound();
return;
}
//Get model from db.
documentModel = await guestDocService.GetDtoByIdAsync(docIdModel.DocumentType, docIdModel.DocumentNum);
if (documentModel is null)
{
Snackbar.Add($"GuestDocument not found with ID: '{docId}'", Severity.Error);
Navigation.NotFound();
return;
}
}
private void BtnEdit()
{
Snackbar.Add("Not implemented yet!", Severity.Info);
}
private void BtnReturn()
{
Navigation.NavigateTo(GuestConsts.Page_GuestDocs_List);
}
}