@page "/messages/create/{UserId:int}"
@using Website.Components.MarkdownEditor


@if (User != null)
{
    <nav aria-label="breadcrumb">
        <ol class="breadcrumb">
            <li class="breadcrumb-item"><a href="/messages">Messages</a></li>
            <li class="breadcrumb-item active" aria-current="page">Send message to @User.Name</li>
        </ol>
    </nav>

    <div class="mb-3">
        <div class="card">
            <div class="card-header">
                Create message
            </div>
            <div class="card-body">
                <EditForm Model="Message" OnValidSubmit="SubmitAsync">
                    <div class="mb-3">
                        <label class="form-label">Title</label>
                        <InputText class="form-control" @bind-Value="Message.Title" />
                        <div class="form-text"></div>
                    </div>
                    <div class="mb-3">
                        <label class="form-label">Content</label>
                        <MarkdownEditor @bind-Value="Reply.Content" EnableToolbar="false" />
                    </div>

                    <DataAnnotationsValidator />
                    <ValidationSummary />

                    <div class="mb-3 d-flex align-content-center">
                        <div>
                            @if (message != null)
                            {
                                <span class="text-danger">@message</span>
                            }
                        </div>
                        <div class="ms-auto">
                            @if (isLoading)
                            {
                                <LoadingButton />
                            }
                            else
                            {
                                <button type="submit" class="btn btn-primary">Submit</button>
                            }
                        </div>
                    </div>                    
                </EditForm>                
            </div>
        </div>
    </div>
} else
{
    if (statusCode == System.Net.HttpStatusCode.NoContent)
    {
        <StatementText>User not found</StatementText>
    } else
    {
        <Progressbar />
    }
}
