@using Microsoft.AspNetCore.Components
@using RpgRoller.Components.Pages.HomeControls

<CharacterFormModal
    Visible="Workspace.State.ShowCreateCharacterModal"
    Title="Create Character"
    SubmitLabel="Create Character"
    NameInputId="character-create-name"
    CampaignInputId="character-create-campaign"
    OwnerUsernameInputId="character-create-owner"
    InitialModel="Workspace.State.CreateCharacterInitialModel"
    FormVersion="Workspace.State.CreateCharacterFormVersion"
    EditingCharacterId="null"
    CampaignOptions="Workspace.State.CharacterCampaignOptions"
    IsMutating="Workspace.State.IsMutating"
    AllowOwnerEdit="false"
    AvailableUsernames="Workspace.State.KnownUsernames"
    CharacterSaved="Workspace.Campaigns.OnCharacterCreatedAsync"
    CancelRequested="Workspace.Campaigns.CloseCharacterModals"/>

<CharacterFormModal
    Visible="Workspace.State.ShowEditCharacterModal"
    Title="Edit Character"
    SubmitLabel="Save Character"
    NameInputId="character-edit-name"
    CampaignInputId="character-edit-campaign"
    OwnerUsernameInputId="character-edit-owner"
    InitialModel="Workspace.State.EditCharacterInitialModel"
    FormVersion="Workspace.State.EditCharacterFormVersion"
    EditingCharacterId="Workspace.State.EditingCharacterId"
    CampaignOptions="Workspace.State.CharacterCampaignOptions"
    IsMutating="Workspace.State.IsMutating"
    AllowOwnerEdit="Workspace.State.CanEditCharacterOwner"
    AvailableUsernames="Workspace.State.KnownUsernames"
    CharacterSaved="Workspace.Campaigns.OnCharacterUpdatedAsync"
    CancelRequested="Workspace.Campaigns.CloseCharacterModals"/>

@code {
    [Parameter, EditorRequired] public WorkspacePageContext Workspace { get; set; } = null!;
}
