@using BackOffice.Services.Content

<MudDialog>
    <DialogContent>
        <MudStack Spacing="2">
            <MudStack Row="true" Justify="Justify.SpaceBetween" AlignItems="AlignItems.Center">
                <MudText Typo="Typo.subtitle1">بخش‌های صفحه</MudText>
                <MudButton Variant="Variant.Filled"
                           Color="Color.Primary"
                           Size="Size.Small"
                           StartIcon="@Icons.Material.Filled.Add"
                           OnClick="AddSection">
                    افزودن بخش
                </MudButton>
            </MudStack>

            <MudDataGrid T="SitePageSectionItemDto"
                         Items="Sections"
                         Hover="true"
                         Dense="true"
                         Elevation="0">
                <Columns>
                    <PropertyColumn Property="x => x.SectionKey" Title="کلید بخش" />
                    <PropertyColumn Property="x => x.Title" Title="عنوان" />
                    <PropertyColumn Property="x => x.SortOrder" Title="ترتیب" />
                    <PropertyColumn Property="x => x.IsActive" Title="وضعیت">
                        <CellTemplate>
                            <MudChip Color="@(context.Item.IsActive ? Color.Success : Color.Error)"
                                     Size="Size.Small">
                                @(context.Item.IsActive ? "فعال" : "غیرفعال")
                            </MudChip>
                        </CellTemplate>
                    </PropertyColumn>
                    <TemplateColumn Title="عملیات" Sortable="false">
                        <CellTemplate>
                            <MudStack Row="true" Spacing="1">
                                <MudTooltip Text="ویرایش">
                                    <MudIconButton Icon="@Icons.Material.Filled.Edit"
                                                   Size="Size.Small"
                                                   Color="Color.Primary"
                                                   OnClick="@(() => EditSection(context.Item))" />
                                </MudTooltip>
                                <MudTooltip Text="حذف">
                                    <MudIconButton Icon="@Icons.Material.Filled.Delete"
                                                   Size="Size.Small"
                                                   Color="Color.Error"
                                                   OnClick="@(() => DeleteSection(context.Item))" />
                                </MudTooltip>
                            </MudStack>
                        </CellTemplate>
                    </TemplateColumn>
                </Columns>
            <NoRecordsContent>
                <MudAlert Severity="Severity.Info" Dense="true" Variant="Variant.Text" Class="my-4">موردی یافت نشد.</MudAlert>
            </NoRecordsContent>
            </MudDataGrid>
        </MudStack>
    </DialogContent>
    <DialogActions>
        <MudButton Color="Color.Default" Variant="Variant.Text" OnClick="Close">
            بستن
        </MudButton>
    </DialogActions>
</MudDialog>
