@using FoodsharingSiegen.Contracts.Entity

@{
    var rowClass = "";
    if (Done) rowClass += " done";
    if (NotNeeded) rowClass += " notneeded";
    if (Alert) rowClass += " fs-alert";
}

<tr class="@rowClass" style="border-top: 5px solid transparent;">
    <th class="text-center align-top pr-2">
        <i class="@IconClass"></i>
    </th>
    <th class="pr-2 align-top">@Caption:</th>
    <td class="align-top">
        @if (Interactions.Count > 0)
        {
            foreach (var interaction in Interactions)
            {
                <div>
                    <span title="@interaction.User.Memo">@interaction.User.Name</span> (@interaction.Date.ToShortDateString())
                    @if (!string.IsNullOrWhiteSpace(interaction.Info))
                    {
                        <span>(<i>@interaction.Info</i>)</span>
                    }

                    @if ((Prospect is not {Complete: true } || interaction.Type == InteractionType.Complete) && AllowAddInteraction)
                    {
                        <span>&nbsp;<a href=""><i class="fa-solid fa-square-xmark" @onclick="async () => await RemoveClick.InvokeAsync(interaction.Id)" @onclick:preventDefault></i></a></span>
                    }

                </div>
            }
        }

        @if (Prospect is not {Complete: true } && (Interactions.Count == 0 || Multiple) && AllowAddInteraction)
        {
            if (Multiple) ButtonText = "+";
            <Button Size="Size.Small" Clicked="AddClick">@ButtonText</Button>
        }
    </td>
</tr>