Files
FoodsharingOnboarding/FoodsharingSiegen.Server/Dialogs/AddInteractionModal.razor.cs
Andre Beging 3d92833199 Refactor term-related settings into a dedicated class
Extracted term-related properties from AppSettings to a new TermSettings class for improved organization and separation of concerns. Updated appsettings.json to reflect the new structure.
2025-03-28 09:01:50 +01:00

104 lines
3.7 KiB
C#

using Blazorise;
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Contracts.Model;
using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
namespace FoodsharingSiegen.Server.Dialogs
{
public partial class AddInteractionModal
{
private Modal ModalReference { get; set; } = null!;
private Interaction Interaction { get; set; } = new();
[Parameter]
public EventCallback<Interaction> OnAdd { get; set; }
[Parameter]
public List<User>? Users { get; set; }
public Guid SelectedUser { get; set; }
private string? _header;
private string? _infoName;
private bool _showInfo;
private bool _showAlert;
private bool _showNotNeeded;
protected override async Task OnParametersSetAsync()
{
if (Users?.Any() == true) SelectedUser = Users.First().Id;
await base.OnParametersSetAsync();
}
public async Task ShowAsync(InteractionType type, Guid? prospectId)
{
if (prospectId == null) return;
_showInfo = false;
_showNotNeeded = false;
_showAlert = false;
_infoName = "Kommentar";
switch (type)
{
case InteractionType.EinAb:
_header = "Einführung eintragen";
_showInfo = true;
_showAlert = true;
_infoName = "Welcher Betrieb?";
break;
case InteractionType.Welcome:
_header = "Begrüßung eintragen";
break;
case InteractionType.IdCheck:
_header = "Ausweisprüfung eintragen";
_showAlert = true;
_showInfo = true;
break;
case InteractionType.PrintPass:
_header = "FS-Ausweis (Print)";
_showNotNeeded = true;
_showInfo = true;
break;
case InteractionType.PdfPass:
_header = "FS-Ausweis (PDF)";
_showNotNeeded = true;
_showInfo = true;
break;
case InteractionType.Verify:
_header = "Verifizierung eintragen";
break;
case InteractionType.Complete:
_header = "Als fertig markieren";
_showInfo = true;
break;
case InteractionType.StepInBriefing:
_header = $"{AppSettings.Terms.StepInName} absolviert";
break;
case InteractionType.ReleasedForVerification:
_header = "Zur Verifizierung freigegeben";
_showInfo = true;
_infoName = "Hinweis";
break;
}
Interaction = new Interaction
{
Type = type,
Date = DateTime.UtcNow,
ProspectID = prospectId.Value
};
await ModalReference.Show();
}
private async Task AddInteraction()
{
Interaction.UserID = SelectedUser;
await OnAdd.InvokeAsync(Interaction);
await ModalReference.Hide();
}
}
}