@using CMSMicroservice.Protobuf.Protos.Package
@using BackOffice.Common.BaseComponents
@using Microsoft.AspNetCore.Components.Forms
@using Tizzani.MudBlazor.HtmlEditor


<MudDialog>
    <DialogContent>
        <MudStack>
            <MudStack Justify="Justify.Center" AlignItems="AlignItems.Center">
                <Image Src="@_srcImage" Width="200" Height="100" ObjectPosition="ObjectPosition.Center" ObjectFit="ObjectFit.Cover" />

                <MudFileUpload T="IBrowserFile" Accept="image/*" FilesChanged="OnImageFileSelect">
                    <ActivatorContent>
                        <MudButton HtmlTag="label"
                                   Variant="Variant.Filled"
                                   Color="Color.Primary"
                                   StartIcon="@Icons.Material.Filled.Image"
                                   ButtonType="ButtonType.Button"
                                  >
                            انتخاب تصویر
                        </MudButton>
                    </ActivatorContent>
                    <SelectedTemplate>
                        @if (context != null)
                        {
                            <MudText Class="mt-2" Typo="Typo.subtitle2">
                                <MudTooltip Text="@context.Name" Inline="true">
                                    @context.Name
                                </MudTooltip>
                            </MudText>
                        }
                        else
                        {
                            <MudText Class="mt-2" Typo="Typo.subtitle2">فایلی انتخاب نشده</MudText>
                        }
                    </SelectedTemplate>
                </MudFileUpload>
            </MudStack>
            <MudStack Row="true" AlignItems="AlignItems.Center">
                <MudItem xs="6">
                    <MudTextField T="string" @bind-Value="Model.Title" Disabled="_isLoading" Label="عنوان" Variant="Variant.Outlined" />
                </MudItem>
                <MudItem xs="6">
                    <MudNumericField T="long" HideSpinButtons="true" @bind-Value="Model.Price" Disabled="_isLoading" Label="قیمت" Variant="Variant.Outlined" />
                </MudItem>
            </MudStack>
            <MudItem xs="12">
                <MudHtmlEditor @bind-Html="Model.Description" MinHeight="300px">
                    <MudHtmlToolbarOptions InsertImage="false" /> <!-- This will exclude the "insert image" toolbar option -->
                </MudHtmlEditor>
            </MudItem>
        </MudStack>
    </DialogContent>
    <DialogActions>
        <MudButton OnClick="Cancel" Disabled="_isLoading">لغو</MudButton>
        <MudButton Color="Color.Primary" OnClick="CallUpdateMethod" Disabled="_isLoading">ثبت</MudButton>
    </DialogActions>
</MudDialog>

