85 lines
4.5 KiB
Plaintext
85 lines
4.5 KiB
Plaintext
@page "/discounts"
|
||
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
|
||
|
||
@inject IDialogService DialogService
|
||
@inject NavigationManager NavigationManager
|
||
@inject ISnackbar Snackbar
|
||
@inject IUserUtility UserUtility
|
||
@inject IRestWrapper RestWrapper
|
||
|
||
<MudStack class="w-full p-8 h-screen bg-[--mud-palette-background-grey]">
|
||
<MudGrid>
|
||
<MudItem xs="12">
|
||
<MudStack Row="true" class="mb-5">
|
||
<MudText Typo="Typo.h4">تخفیفــــ ها</MudText>
|
||
<MudChip Color="Color.Info" Variant="Variant.Outlined">124 عدد</MudChip>
|
||
<MudSpacer />
|
||
<MudButton Variant="Variant.Filled"
|
||
DisableElevation="true"
|
||
StartIcon="@Icons.Material.Outlined.Add"
|
||
Color="Color.Secondary"
|
||
OnClick="@ViewModel.AddAsync"
|
||
class="my-auto">افزودن تخفیفــ جدید</MudButton>
|
||
</MudStack>
|
||
<MudPaper>
|
||
<MudDataGrid FixedFooter="true" FixedHeader="true" Striped="true"
|
||
T="DiscountSDto" Items="@ViewModel.PageDto" CurrentPage="@ViewModel.CurrentPage"
|
||
RowsPerPage="20" Filterable="false" Loading="@ViewModel.IsProcessing"
|
||
SortMode="@SortMode.None" Groupable="false">
|
||
|
||
<ToolBarContent>
|
||
<MudTextField T="string" Placeholder="جست جو بر اساس نام" Adornment="Adornment.Start" Immediate="true"
|
||
Clearable="true"
|
||
ValueChanged="@ViewModel.SearchChanged"
|
||
AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" class="my-auto"
|
||
OnAdornmentClick="@ViewModel.SearchAsync"></MudTextField>
|
||
</ToolBarContent>
|
||
<Columns>
|
||
<PropertyColumn Title="کد تخفیفــ" Property="arg => arg.Code" />
|
||
<PropertyColumn Title="تعداد" Property="arg => arg.Count" />
|
||
<PropertyColumn Title="تاریخ شروع" Property="arg => arg.StartDate" />
|
||
<PropertyColumn Title="تاریخ انقضا" Property="arg => arg.ExpireDate" />
|
||
<PropertyColumn Title="پیشنهاد ویژه" Property="arg => arg.IsSpecialOffer" />
|
||
<PropertyColumn Title="تعداد استفاده شده" Property="arg => arg.UseCount" />
|
||
<TemplateColumn CellClass="d-flex justify-end">
|
||
<CellTemplate>
|
||
<MudStack Row="true">
|
||
<MudIconButton Icon="@Icons.Material.Filled.Edit"
|
||
Size="@Size.Small"
|
||
Variant="@Variant.Outlined"
|
||
Color="@Color.Info"
|
||
OnClick="async()=>await ViewModel.EditAsync(context.Item)" />
|
||
<MudIconButton Icon="@Icons.Material.Filled.Delete"
|
||
Size="@Size.Small"
|
||
Variant="@Variant.Outlined"
|
||
OnClick="async () => await ViewModel.DeleteAsync(context.Item.Id)"
|
||
Color="@Color.Error" />
|
||
</MudStack>
|
||
</CellTemplate>
|
||
</TemplateColumn>
|
||
</Columns>
|
||
<PagerContent>
|
||
<MudStack Row="true" class="w-full">
|
||
|
||
<MudPagination Rectangular="true" Variant="Variant.Filled" Count="@ViewModel.PageCount"
|
||
SelectedChanged="@ViewModel.ChangePageAsync" class="my-4 mx-auto" />
|
||
</MudStack>
|
||
|
||
</PagerContent>
|
||
</MudDataGrid>
|
||
</MudPaper>
|
||
</MudItem>
|
||
</MudGrid>
|
||
</MudStack>
|
||
|
||
@code
|
||
{
|
||
public DiscountPageViewModel ViewModel { get; set; }
|
||
protected override async Task OnInitializedAsync()
|
||
{
|
||
ViewModel = new DiscountPageViewModel(NavigationManager, Snackbar, UserUtility, RestWrapper, DialogService);
|
||
await ViewModel.InitializeAsync();
|
||
await base.OnInitializedAsync();
|
||
}
|
||
}
|