Files
FoodsharingOnboarding/FoodsharingSiegen.Server/Controls/ProspectContainer.razor.cs
Andre Beging 350e2003ca Add new filters and refactor InteractionDialog handling
Introduced new filters for prospects: "WithoutIdCheck" and "NoActivity" with associated UI controls. Refactored `InteractionDialog.ShowAsync` to use a new parameter record for cleaner code and better extensibility. These changes enhance usability and maintainability by providing additional filtering options and streamlining dialog interactions.
2025-03-28 20:07:12 +01:00

74 lines
2.8 KiB
C#

using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.Data.Service;
using FoodsharingSiegen.Server.Dialogs;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Controls
{
public partial class ProspectContainer
{
[Parameter] public Prospect? Prospect { get; set; }
[Parameter] public ProspectStateFilter StateFilter { get; set; }
[Parameter] public string? CssClass { get; set; }
[Parameter] public Func<Task>? OnDataChanged { get; set; }
private async Task AddInteraction(InteractionType type)
{
if (Prospect != null && OnDataChanged != null)
{
var headerText = type switch
{
InteractionType.EinAb => "Einführung eintragen",
InteractionType.Welcome => "Begrüßung eintragen",
InteractionType.IdCheck => "Ausweisprüfung eintragen",
InteractionType.PrintPass => "FS-Ausweis (Print)",
InteractionType.PdfPass => "FS-Ausweis (PDF)",
InteractionType.Verify => "Verifizierung eintragen",
InteractionType.Complete => "Als fertig markieren",
InteractionType.StepInBriefing => $"{AppSettings.Terms.StepInName} absolviert",
InteractionType.ReleasedForVerification => "Zur Verifizierung freigegeben",
_ => "Neuer Eintrag"
};
await InteractionDialog.ShowAsync(ModalService, new(type, Prospect.Id, headerText, OnDataChanged));
}
}
private List<Interaction> GetTyped(InteractionType type)
{
return Prospect?.Interactions?.Where(x => x.Type == type).ToList() ?? [];
}
private async Task EditProspectAsync()
{
await EditProspectDialog.ShowAsync(ModalService, () => InvokeAsync(StateHasChanged), Prospect);
}
/// <summary>
/// Gets or sets the value of the prospect service (ab)
/// </summary>
[Inject]
public ProspectService ProspectService { get; set; } = null!;
private async Task RemoveInteraction(Guid arg)
{
var confirm = await Message.Confirm("Interaktion wirklich löschen?", "Bestätigen", o =>
{
o.ConfirmButtonText = "Ja, wirklich!";
o.CancelButtonText = "Abbrechen";
o.ShowMessageIcon = false;
});
if (confirm)
{
var removeR = await ProspectService.RemoveInteraction(arg);
if(removeR.Success && OnDataChanged != null) await OnDataChanged();
}
}
}
}