feat(AddFeatureFastProduct) , fix(CheckUserDiscount) , fix(SideBar)

- Add feature in fast product create dialog box
- Fix user fist use discount check user
- Fix sidebar
subProduct
Amir Hossein Khademi 2024-06-24 22:32:44 +03:30
parent 82ace9a4dd
commit edf22ff1ca
7 changed files with 95 additions and 42 deletions

View File

@ -5,7 +5,7 @@
<MudStack class="bg-[--mud-palette-background] h-screen w-full pt-4"> <MudStack class="bg-[--mud-palette-background] h-screen w-full pt-4">
<MudNavMenu Rounded="true" Margin="Margin.Dense" Color="Color.Warning" Class="pa-2" Bordered="true"> <MudNavMenu Rounded="true" Margin="Margin.Dense" Color="Color.Warning" Bordered="true">
<MudNavLink Href="home" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Dashboard">داشبورد</MudNavLink> <MudNavLink Href="home" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Dashboard">داشبورد</MudNavLink>
@if (isShop) @if (isShop)
{ {

View File

@ -6,7 +6,7 @@
<MudDialog class="mx-auto h-screen overflow-y-auto p-0"> <MudDialog class="mx-auto h-screen overflow-y-auto p-0">
<DialogContent> <DialogContent>
<MudContainer class="p-0 text-black"> <MudContainer class="p-0">
<MudStack Row="true"> <MudStack Row="true">
<MudText Typo="Typo.h6" class="my-auto">افزودن سریع محصول</MudText> <MudText Typo="Typo.h6" class="my-auto">افزودن سریع محصول</MudText>
<MudSpacer /> <MudSpacer />
@ -92,6 +92,52 @@
<MudTextField Disabled="@ViewModel.FormEnable.Not()" @bind-Value="@ViewModel.PageDto.Cost" Format="N0" Variant="Variant.Outlined" T="double" Label="قیمت ( تومان )" /> <MudTextField Disabled="@ViewModel.FormEnable.Not()" @bind-Value="@ViewModel.PageDto.Cost" Format="N0" Variant="Variant.Outlined" T="double" Label="قیمت ( تومان )" />
</MudItem> </MudItem>
</MudGrid> </MudGrid>
<MudExpansionPanels>
<MudExpansionPanel Text="ویژگی ها ( اختیاری )">
<MudGrid>
<MudItem xs="12" lg="6" md="6">
<MudTextField @bind-Value="@ViewModel.SpecificationTitle" T="string" Label="عنوان" Variant="Variant.Outlined"></MudTextField>
</MudItem>
<MudItem xs="12" lg="6" md="6">
<MudStack Row="true">
<MudTextField @bind-Value="@ViewModel.SpecificationValue" T="string" Label="مقدار" Variant="Variant.Outlined"></MudTextField>
<MudButton Variant="Variant.Filled"
Size="Size.Large"
Color="Color.Info"
class="mt-2 py-2"
OnClick="ViewModel.AddSpecification"
StartIcon="@Icons.Material.Outlined.Add">افزودن</MudButton>
</MudStack>
</MudItem>
<MudItem xs="12">
<MudDataGrid Items="@ViewModel.Specifications" Elevation="0" Outlined="true" Bordered="true" Striped="true" Filterable="false" SortMode="@SortMode.None" Groupable="false">
<Columns>
<PropertyColumn Property="x => x.Title" Title="عنوان" />
<PropertyColumn Property="x => x.Value" Title="مقدار" />
<TemplateColumn T="SpecificationSDto" CellClass="d-flex justify-end">
<CellTemplate>
<MudStack Row>
<MudButton DisableElevation="true"
Size="@Size.Small"
Variant="@Variant.Filled"
OnClick="()=>ViewModel.RemoveSpecification(context.Item)"
Color="@Color.Error"
StartIcon="@Icons.Material.Outlined.Delete">حذف</MudButton>
</MudStack>
</CellTemplate>
</TemplateColumn>
</Columns>
</MudDataGrid>
</MudItem>
</MudGrid>
</MudExpansionPanel>
</MudExpansionPanels>
<MudFileUpload T="IReadOnlyList<IBrowserFile>" <MudFileUpload T="IReadOnlyList<IBrowserFile>"
AppendMultipleFiles AppendMultipleFiles
OnFilesChanged="@ViewModel.OnInputFileChanged" OnFilesChanged="@ViewModel.OnInputFileChanged"

View File

@ -24,7 +24,7 @@ public class FastProductCreateDialogBoxViewModel(ISnackbar snackbar, IRestWrappe
{ {
var categories = await restWrapper.ProductCategoryRestApi.ReadAll(true); var categories = await restWrapper.ProductCategoryRestApi.ReadAll(true);
categories.ForEach(c => Categories.Add(c)); categories.ForEach(c => Categories.Add(c));
PageDto.Stock = 1; PageDto.Stock = 10;
await base.InitializeAsync(); await base.InitializeAsync();
} }
@ -90,7 +90,7 @@ public class FastProductCreateDialogBoxViewModel(ISnackbar snackbar, IRestWrappe
var token = await userUtility.GetBearerTokenAsync(); var token = await userUtility.GetBearerTokenAsync();
if (token == null) if (token == null)
return; return;
var command = brand.Adapt<CreateBrandCommand>() with {Files = new()}; var command = brand.Adapt<CreateBrandCommand>() with { Files = new() };
var response = await restWrapper.CrudApiRest<Brand, Guid>(Address.BrandController) var response = await restWrapper.CrudApiRest<Brand, Guid>(Address.BrandController)
.Create(command, token); .Create(command, token);
brand.Id = response; brand.Id = response;
@ -110,6 +110,7 @@ public class FastProductCreateDialogBoxViewModel(ISnackbar snackbar, IRestWrappe
var product = PageDto.Clone(); var product = PageDto.Clone();
var brand = SelectedBrand.Clone(); var brand = SelectedBrand.Clone();
var browserFiles = Files.ToList(); var browserFiles = Files.ToList();
var specifications = Specifications.ToList();
Task.Run(async () => Task.Run(async () =>
{ {
var token = await userUtility.GetBearerTokenAsync(); var token = await userUtility.GetBearerTokenAsync();
@ -136,19 +137,23 @@ public class FastProductCreateDialogBoxViewModel(ISnackbar snackbar, IRestWrappe
FileType = StorageFileType.Image FileType = StorageFileType.Image
}); });
} }
product.Cost *= 10;
var command = product.Adapt<CreateProductCommand>() with var command = product.Adapt<CreateProductCommand>() with
{ {
BeDisplayed = true, BeDisplayed = true,
BrandId = brand.Id, BrandId = brand.Id,
CategoryId = SelectedCategory.Id, CategoryId = SelectedCategory.Id,
Files = files Files = files,
Specifications = specifications
}; };
await restWrapper.CrudApiRest<Product, Guid>(Address.ProductController) await restWrapper.CrudApiRest<Product, Guid>(Address.ProductController)
.Create(command, token); .Create(command, token);
}); });
PageDto = new ProductLDto{Stock = 1}; PageDto = new ProductLDto { Stock = 1 };
FileNames.Clear(); FileNames.Clear();
//Specifications.Clear();
Files.Clear(); Files.Clear();
} }
catch (Exception e) catch (Exception e)
@ -156,4 +161,35 @@ public class FastProductCreateDialogBoxViewModel(ISnackbar snackbar, IRestWrappe
snackbar.Add(e.Message, Severity.Error); snackbar.Add(e.Message, Severity.Error);
} }
} }
public string SpecificationTitle = string.Empty;
public string SpecificationValue = string.Empty;
public readonly ObservableCollection<SpecificationSDto> Specifications = new ObservableCollection<SpecificationSDto>();
public void AddSpecification()
{
try
{
if (SpecificationTitle.IsNullOrEmpty())
throw new AppException("عنوان ویژگی مورد نظر را وارد کنید");
if (SpecificationValue.IsNullOrEmpty())
throw new AppException("مقدار ویژگی مورد نظر را وارد کنید");
Specifications.Add(new SpecificationSDto { Title = SpecificationTitle.ToString(), Value = SpecificationValue.ToString() });
SpecificationTitle = string.Empty;
SpecificationValue = string.Empty;
}
catch (Exception e)
{
snackbar.Add(e.Message, Severity.Error);
}
}
public void RemoveSpecification(SpecificationSDto specification)
{
var spec = Specifications.FirstOrDefault(s => s.Value == specification.Value && s.Title == specification.Title);
if (spec != null)
Specifications.Remove(spec);
}
} }

View File

@ -5,8 +5,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest> <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<AssemblyVersion>1.0.3.4</AssemblyVersion> <AssemblyVersion>1.1.8.11</AssemblyVersion>
<FileVersion>1.0.3.4</FileVersion> <FileVersion>1.1.8.11</FileVersion>
<AssemblyName>$(MSBuildProjectName)</AssemblyName> <AssemblyName>$(MSBuildProjectName)</AssemblyName>
</PropertyGroup> </PropertyGroup>

View File

@ -10,7 +10,7 @@
background-color: var(--mud-palette-background-grey); background-color: var(--mud-palette-background-grey);
} }
</style> *@ </style> *@
<MudPaper class="h-full w-full p-3 md:p-8"> <MudStack class="h-full w-full p-3 md:p-8">
<MudStack Row="true" class="overflow-x-auto pb-3"> <MudStack Row="true" class="overflow-x-auto pb-3">
<MudStack Spacing="1" class="min-w-[340px]"> <MudStack Spacing="1" class="min-w-[340px]">
<MudStack Row="true" class="mb-5"> <MudStack Row="true" class="mb-5">
@ -105,7 +105,7 @@
</MudStack> </MudStack>
</MudPaper> </MudStack>
@code @code
{ {

View File

@ -1784,10 +1784,6 @@ input:checked + .toggle-bg {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(217 119 6 / var(--tw-text-opacity)); color: rgb(217 119 6 / var(--tw-text-opacity));
} }
.text-black {
--tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity));
}
.text-blue-600 { .text-blue-600 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(28 100 242 / var(--tw-text-opacity)); color: rgb(28 100 242 / var(--tw-text-opacity));

View File

@ -1259,10 +1259,6 @@ input:checked + .toggle-bg {
margin-top: -0.75rem; margin-top: -0.75rem;
} }
.-mt-\[3px\] {
margin-top: -3px;
}
.mb-1 { .mb-1 {
margin-bottom: 0.25rem; margin-bottom: 0.25rem;
} }
@ -1339,22 +1335,6 @@ input:checked + .toggle-bg {
margin-top: 2rem; margin-top: 2rem;
} }
.-mt-\[4px\] {
margin-top: -4px;
}
.-mt-\[2px\] {
margin-top: -2px;
}
.-mt-\[5px\] {
margin-top: -5px;
}
.-mt-\[0\.15rem\] {
margin-top: -0.15rem;
}
.block { .block {
display: block; display: block;
} }
@ -2095,11 +2075,6 @@ input:checked + .toggle-bg {
color: rgb(217 119 6 / var(--tw-text-opacity)); color: rgb(217 119 6 / var(--tw-text-opacity));
} }
.text-black {
--tw-text-opacity: 1;
color: rgb(0 0 0 / var(--tw-text-opacity));
}
.text-blue-600 { .text-blue-600 {
--tw-text-opacity: 1; --tw-text-opacity: 1;
color: rgb(28 100 242 / var(--tw-text-opacity)); color: rgb(28 100 242 / var(--tw-text-opacity));