<h3>HomeworkDisplay</h3>

@attribute [Authorize]
@using Microsoft.AspNetCore.Authorization
@using WorkManagementTool.Services
@using WorkManagementTool.Data.Entities;

@inject HomeworkService HomeworkService

@if (homework is null)
{
    <p>Homework not found</p>
}
else
{
    <dl>
        <dh>Title</dh>
        <dd>@homework.Title</dd>

        <dh>Description</dh>
        <dd>@homework.Description</dd>

        <dh>Due date</dh>
        <dd>@homework.DueDate</dd>

        <dh>Completed</dh>
        <dd>@homework.IsCompleted</dd>
    </dl>
}

@code {
    [Parameter]
    public int Id { get; set; }

    private Homework? homework;

    protected override async Task OnInitializedAsync()
    {
        homework = await HomeworkService.GetHomeworkByIdAsync(Id);
    }
}
