@using Entities.DTO

<MudPaper Class="overflow-hidden " Style="background-color:pink" Width="@Width" Height="@Height" MaxHeight="@MaxHeight" MaxWidth="@MaxWidth">
	<MudPaper Class="d-flex flex-column flex-grow-1 justify-content-between" Height="100%" Style="background-color:green">

		<MudText Typo="Typo.body2"> @AssignmentDto.Title </MudText>


		<MudPaper>

			<MudButtonGroup Size="Size.Small" Color="Color.Primary" Variant="Variant.Filled">

				<MudButton OnClick="ExamClick"> 详情 </MudButton>
				<MudIconButton Icon="@Icons.Material.Filled.Delete" aria-label="delete" />
				@if (bteacher)
				{
					<MudIconButton Icon="@Icons.Material.Filled.Check" OnClick="CheckExam" Color="Color.Primary" aria-label="github" />
				}

				<MudIconButton Icon="@Icons.Material.Filled.Favorite" Color="Color.Secondary" aria-label="add to favorite" />
			</MudButtonGroup>
		</MudPaper>

	</MudPaper>
</MudPaper>

@code {
	[CascadingParameter]
	private Task<AuthenticationState> authenticationStateTask { get; set; }

	private bool bteacher = false;

	[Inject]
	public NavigationManager navigationManager { get; set; }

	[Parameter]
	public AssignmentDto AssignmentDto { get; set; }


	[Parameter]
	public string? Width { get; set; } = "256";


	[Parameter]
	public string? Height { get; set; } = "64";


	[Parameter]
	public string? MaxWidth { get; set; } = "256";


	[Parameter]
	public string? MaxHeight { get; set; } = "64";


	protected override Task OnInitializedAsync()
	{
		bteacher = authenticationStateTask.Result.User.IsInRole("Teacher");
		return base.OnInitializedAsync();
	}

	private void ExamClick()
	{
		navigationManager.NavigateTo($"exam/edit/{AssignmentDto.Id}");
	}

	private void CheckExam()
	{
		navigationManager.NavigateTo($"exam/check/{AssignmentDto.Id}");
	}
}
