@using CouchLog.Data

<MudCard>
    <MudPaper Elevation="0">
        <MudCardMedia Image="@GlobalEntity.PicturePath" Height="400" Style="object-fit: contain;"/>
    </MudPaper>
    <MudCardContent>
        <MudText Typo="Typo.h5">@GlobalEntity.Title</MudText>
    </MudCardContent>
    <MudCardActions>
        <MudTooltip Text="Add to shared List">
            <MudIconButton Icon="@Icons.Material.Rounded.People" Color="Color.Primary" OnClick="@(() => OnAddToShared.InvokeAsync(GlobalEntity))" />
        </MudTooltip>
        <MudSpacer/>
        @if (UserPrivateEntityIds.Contains(GlobalEntity.Id))
        {
            <MudTooltip Text="Already added to Private List">
                <MudIconButton Icon="@Icons.Material.Rounded.Check" Color="Color.Primary"/>
            </MudTooltip>
        }
        else
        {
            <MudTooltip Text="Add to private List">
                <MudIconButton Icon="@Icons.Material.Rounded.Lock" Color="Color.Primary" OnClick="@(() => OnAddToPrivate.InvokeAsync(GlobalEntity))" />
            </MudTooltip>
        }
    </MudCardActions>
</MudCard>

@code
{
    [Parameter] public GlobalEntity GlobalEntity { get; set; } = null!;
    [Parameter] public HashSet<int> UserPrivateEntityIds { get; set; } = null!;
    
    [Parameter] public EventCallback<GlobalEntity> OnAddToPrivate { get; set; }
    [Parameter] public EventCallback<GlobalEntity> OnAddToShared { get; set; }
}
