Refactor interaction handling with utility for translations

Introduced `TermHelper.Translate` to centralize string mappings for `InteractionType`, reducing duplication across components. Updated related code to leverage this utility and streamline interaction row implementation by removing the `Caption` parameter. Minor UI adjustments were also made to align button positioning and styling.
This commit is contained in:
Andre Beging
2025-03-28 20:31:25 +01:00
parent 350e2003ca
commit 0324e0f529
7 changed files with 70 additions and 45 deletions

View File

@@ -1,4 +1,5 @@
using FoodsharingSiegen.Contracts.Entity;
using FoodsharingSiegen.Server.BaseClasses;
using Microsoft.AspNetCore.Components;
namespace FoodsharingSiegen.Server.Controls
@@ -6,7 +7,7 @@ namespace FoodsharingSiegen.Server.Controls
/// <summary>
/// The interaction row class (a. beging, 31.05.2022)
/// </summary>
public partial class InteractionRow
public partial class InteractionRow : FsBase
{
#region Parameters
@@ -14,7 +15,7 @@ namespace FoodsharingSiegen.Server.Controls
/// Gets or sets the value of the add click (ab)
/// </summary>
[Parameter]
public EventCallback AddClick { get; set; }
public Func<InteractionType, Task>? AddClick { get; set; }
/// <summary>
/// Gets or sets the value of the allow add interaction (ab)
@@ -28,12 +29,6 @@ namespace FoodsharingSiegen.Server.Controls
[Parameter]
public string? ButtonIconClass { get; set; }
/// <summary>
/// Gets or sets the value of the caption (ab)
/// </summary>
[Parameter]
public string? Caption { get; set; }
/// <summary>
/// Gets or sets the value of the icon class (ab)
/// </summary>
@@ -87,7 +82,7 @@ namespace FoodsharingSiegen.Server.Controls
/// <summary>
/// Gets the value of the interactions (ab)
/// </summary>
private List<Interaction> Interactions => Prospect?.Interactions?.Where(x => x.Type == Type).ToList() ?? new List<Interaction>();
private List<Interaction> Interactions => Prospect?.Interactions.Where(x => x.Type == Type).ToList() ?? [];
/// <summary>
/// Gets the value of the not needed (ab)