@page "/todo"

@inherits FsBase

<PageTitle>Freischalten - @AppSettings.Title</PageTitle>

<h2>Freischalten</h2>

@{
    var filterListQ = ProspectList?.AsQueryable();
    if (!string.IsNullOrWhiteSpace(Filter.Text))
    {
        filterListQ = filterListQ?
            .Where(x =>
                x.Name.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) ||
                (!string.IsNullOrWhiteSpace(x.Memo) && x.Memo.Contains(Filter.Text, StringComparison.OrdinalIgnoreCase) == true) ||
                x.FsId.ToString().Contains(Filter.Text, StringComparison.OrdinalIgnoreCase)).AsQueryable();
    }
    
    if (Filter.WithoutStepInBriefing)
        filterListQ = filterListQ?.Where(x => x.Interactions.All(i => i.Type != InteractionType.StepInBriefing));
        
    var filterList = filterListQ?.ToList();
}

<hr/>
<ProspectFilterControl @bind-Filter="Filter"></ProspectFilterControl>
<hr />
<h5>@(filterList?.Count ?? 0) Einträge</h5>
@if (filterList?.Any() == true)
{
    <div class="row m-0">
        <Repeater Items="@filterList">
            <ProspectContainer Prospect="context" InteractionModal="InteractionModal" ProspectModal="ProspectModal" RemoveInteraction="RemoveInteraction" StateFilter="ProspectStateFilter.Verification"></ProspectContainer>
        </Repeater>
    </div>
}

<AddProspectModal @ref="ProspectModal" OnUpdate="OnUpdateProspect"></AddProspectModal>
<AddInteractionModal @ref="InteractionModal" OnAdd="OnAddInteraction" Users="Users"></AddInteractionModal>