diff --git a/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor b/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor index 5bc4036..4f2a0d1 100644 --- a/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor +++ b/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor @@ -65,13 +65,12 @@ - - سوالات متداول + سوالات متداول - + فروشگاه نقش ها و کاربران diff --git a/NetinaShop.AdminPanel.PWA/Extensions/StorageFileExtension.cs b/NetinaShop.AdminPanel.PWA/Extensions/StorageFileExtension.cs index 9f55872..4434f51 100644 --- a/NetinaShop.AdminPanel.PWA/Extensions/StorageFileExtension.cs +++ b/NetinaShop.AdminPanel.PWA/Extensions/StorageFileExtension.cs @@ -6,7 +6,7 @@ public static class StorageFileExtension { public static string GetLink(this StorageFileSDto file) { - var link = $"https://storage.vesmook.com/{file.FileLocation}"; + var link = $"https://storage.vesmeh.com/{file.FileLocation}"; return link; } } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Models/Address.cs b/NetinaShop.AdminPanel.PWA/Models/Address.cs index e070c12..1ff87cd 100644 --- a/NetinaShop.AdminPanel.PWA/Models/Address.cs +++ b/NetinaShop.AdminPanel.PWA/Models/Address.cs @@ -3,8 +3,8 @@ public static class Address { #if DEBUG - //public static string BaseAddress = "http://localhost:32770/api"; - public static string BaseAddress = "https://api.vesmeh.com/api"; + public static string BaseAddress = "http://localhost:32770/api"; + //public static string BaseAddress = "https://api.vesmeh.com/api"; #else public static string BaseAddress = "https://api.vesmeh.com/api"; #endif @@ -25,4 +25,6 @@ public static class Address public static string ScraperController => $"{BaseAddress}/scraper"; public static string NewsletterMemberController => $"{BaseAddress}/newsletter/member"; public static string DashboardController => $"{BaseAddress}/dashboard"; + public static string SettingController => $"{BaseAddress}/setting"; + public static string DistrictController => $"{BaseAddress}/district"; } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj b/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj index ca8cdbb..4d74437 100644 --- a/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj +++ b/NetinaShop.AdminPanel.PWA/NetinaShop.AdminPanel.PWA.csproj @@ -5,8 +5,8 @@ enable enable service-worker-assets.js - 0.17.20.30 - 0.17.20.30 + 0.17.21.31 + 0.17.21.31 $(MSBuildProjectName) @@ -85,6 +85,8 @@ + + diff --git a/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor b/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor index 20865fc..ca8c6cb 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor @@ -1,4 +1,4 @@ -@page "/faqs" +@page "/management/faqs" @attribute [Microsoft.AspNetCore.Authorization.Authorize] @inject IDialogService DialogService diff --git a/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor.cs b/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor.cs index db0931e..8fc3861 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor.cs +++ b/NetinaShop.AdminPanel.PWA/Pages/FaqManagementPage.razor.cs @@ -1,6 +1,4 @@ -using NetinaShop.Domain.Entities.Pages; - -namespace NetinaShop.AdminPanel.PWA.Pages; +namespace NetinaShop.AdminPanel.PWA.Pages; public class FaqManagementPageViewModel : BaseViewModel { diff --git a/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor b/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor new file mode 100644 index 0000000..f464325 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor @@ -0,0 +1,148 @@ +@page "/management/shop" +@using NetinaShop.Domain.Models.Districts +@attribute [Microsoft.AspNetCore.Authorization.Authorize] + +@inject IDialogService DialogService +@inject NavigationManager NavigationManager +@inject ISnackbar Snackbar +@inject IUserUtility UserUtility +@inject IRestWrapper RestWrapper + + + + + + + + فروشـــــگاه من + شما می توانید اطلاعات فروشگاه خود را ویرایش نمایید + + + + + + + + + + + + + + + + + + + + + + + + + + + + بلی + خیر + + + + + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
+
+ + + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
+
+ + + + + + + + + +
+
+ + + + + تنظیمات درگاه پرداخت + شما می توانید اطلاعات درگاه پرداخت خود را ویرایش نمایید + + + + + + + + + + + + + + + +
+
+
+ +@code +{ + public ShopManagementPageViewModel ViewModel { get; set; } + protected override async Task OnInitializedAsync() + { + ViewModel = new ShopManagementPageViewModel(NavigationManager, Snackbar, UserUtility, RestWrapper, DialogService); + await ViewModel.InitializeAsync(); + await base.OnInitializedAsync(); + } +} diff --git a/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor.cs b/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor.cs new file mode 100644 index 0000000..5ce3944 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Pages/ShopManagementPage.razor.cs @@ -0,0 +1,182 @@ +using NetinaShop.Domain.MartenEntities.Settings; +using NetinaShop.Domain.Models.Districts; + +namespace NetinaShop.AdminPanel.PWA.Pages; + +public class ShopManagementPageViewModel : BaseViewModel +{ + + private readonly NavigationManager _navigationManager; + private readonly ISnackbar _snackbar; + private readonly IUserUtility _userUtility; + private readonly IDialogService _dialogService; + private readonly IRestWrapper _restWrapper; + + public ShopSetting ShopSetting { get; set; } = new ShopSetting(); + public PaymentSetting PaymentSetting { get; set; } = new PaymentSetting(); + + public List Cities = new List(); + public City SelectedCity = new City(); + public List Provinces = new List(); + public Province SelectedProvince = new Province(); + + + public ShopManagementPageViewModel(NavigationManager navigationManager, ISnackbar snackbar, IUserUtility userUtility, IRestWrapper restWrapper, IDialogService dialogService) + { + _navigationManager = navigationManager; + _snackbar = snackbar; + _userUtility = userUtility; + _restWrapper = restWrapper; + _dialogService = dialogService; + } + + public override async Task InitializeAsync() + { + try + { + IsProcessing = true; + var token = await _userUtility.GetBearerTokenAsync(); + if (token == null) + throw new Exception("Token is null"); + + ShopSetting = await _restWrapper.SettingRestApi.GetSettingAsync("ShopSetting", token); + + if (ShopSetting.CityId != 0) + SelectedCity = new City { Id = ShopSetting.CityId, Name = ShopSetting.City }; + + if (ShopSetting.ProvinceId != 0) + SelectedProvince = new Province { Id = ShopSetting.ProvinceId, Name = ShopSetting.Province }; + + PaymentSetting = await _restWrapper.SettingRestApi.GetSettingAsync("PaymentSetting", token); + + } + catch (ApiException e) + { + var exe = await e.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : e.Content, Severity.Error); + } + catch (Exception ex) + { + _snackbar.Add(ex.Message, Severity.Error); + } + finally + { + IsProcessing = false; + } + + await base.InitializeAsync(); + } + + public async Task> SearchCityAsync(string city) + { + try + { + if (SelectedProvince.Id == default) + throw new Exception("لطفا استان را انتخاب کنید"); + + Cities = await _restWrapper.DistrictApiRest.GetCitiesAsync(SelectedProvince.Id); + + if (city.IsNullOrEmpty()) + return Cities; + return Cities.Where(c => c.Name.Contains(city)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + _snackbar.Add(exe.Message, Severity.Error); + _snackbar.Add(ex.Content, Severity.Error); + return Cities; + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + return Cities; + } + } + + public async Task> SearchProvinceAsync(string province) + { + try + { + Provinces = await _restWrapper.DistrictApiRest.GetProvincesAsync(); + + if (province.IsNullOrEmpty()) + return Provinces; + return Provinces.Where(c => c.Name.Contains(province)); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + if (exe != null) + _snackbar.Add(exe.Message, Severity.Error); + _snackbar.Add(ex.Content, Severity.Error); + return Provinces; + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + return Provinces; + } + } + + public async Task SubmitShopSettingAsync() + { + try + { + if (SelectedProvince.Id == default) + throw new Exception("لطفا استان را انتخاب کنید"); + if (SelectedCity.Id == default) + throw new Exception("لطفا شهر را انتخاب نمایید"); + + ShopSetting.CityId = SelectedCity.Id; + ShopSetting.ProvinceId = SelectedProvince.Id; + ShopSetting.City = SelectedCity.Name; + ShopSetting.Province = SelectedProvince.Name; + + var token = await _userUtility.GetBearerTokenAsync(); + if (token == null) throw new Exception("Token is null"); + await _restWrapper.SettingRestApi.PostSettingAsync("ShopSetting", ShopSetting, token); + _snackbar.Add("تنظیمات فروشگاه با موفقیت به روز شد", Severity.Success); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + } + finally + { + IsProcessing = false; + } + + } + + public async Task SubmitPaymentSettingAsync() + { + try + { + var token = await _userUtility.GetBearerTokenAsync(); + if (token == null) throw new Exception("Token is null"); + await _restWrapper.SettingRestApi.PostSettingAsync("PaymentSetting", PaymentSetting, token); + _snackbar.Add("تنظیمات فروشگاه با موفقیت به روز شد", Severity.Success); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + } + finally + { + IsProcessing = false; + } + + } +} \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Pages/UserSettingsPage.razor b/NetinaShop.AdminPanel.PWA/Pages/UserSettingsPage.razor index cdd626e..8b54cbd 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/UserSettingsPage.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/UserSettingsPage.razor @@ -1,4 +1,4 @@ -@page "/users" +@page "/setting/user" @using NetinaShop.Domain.Entities.Users @attribute [Microsoft.AspNetCore.Authorization.Authorize] diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IDistrictApiRest.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IDistrictApiRest.cs new file mode 100644 index 0000000..3e643b5 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IDistrictApiRest.cs @@ -0,0 +1,13 @@ +namespace NetinaShop.AdminPanel.PWA.Services.RestServices; + +public interface IDistrictApiRest +{ + [Get("/city")] + public Task> GetCitiesAsync(); + + [Get("/city")] + public Task> GetCitiesAsync([Query]int provinceId); + + [Get("/province")] + public Task> GetProvincesAsync(); +} \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IPageRestApi.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IPageRestApi.cs index e6b5a81..171648e 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/IPageRestApi.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IPageRestApi.cs @@ -4,10 +4,10 @@ public interface IPageRestApi { [Get("/type/{type}")] - Task ReadByType([Query] string type, [Header("Authorization")] string authorization); + Task ReadByType([Query] string type, [Header("Authorization")] string authorization); [Get("/{id}")] - Task ReadById(Guid id, [Header("Authorization")] string authorization); + Task ReadById(Guid id, [Header("Authorization")] string authorization); [Post("")] Task CreatePage([Body] PageActionRequestDto request, [Header("Authorization")] string authorization); diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs index 2f582e2..3f487b1 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/IRestWrapper.cs @@ -21,4 +21,6 @@ public interface IRestWrapper public IPageRestApi PageRestApi { get; } public IScraperRestApi ScraperRestApi { get; } public IDashboardApiRest DashboardApiRest { get; } + public ISettingRestApi SettingRestApi { get; } + public IDistrictApiRest DistrictApiRest { get; } } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/ISettingRestApi.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/ISettingRestApi.cs new file mode 100644 index 0000000..db12fc3 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/ISettingRestApi.cs @@ -0,0 +1,10 @@ +namespace NetinaShop.AdminPanel.PWA.Services.RestServices; + +public interface ISettingRestApi +{ + [Get("/{settingName}")] + public Task GetSettingAsync(string settingName, [Header("Authorization")] string authorization) where TSetting : class; + + [Post("/{settingName}")] + public Task PostSettingAsync(string settingName,[Body]TSetting setting , [Header("Authorization")]string authorization) where TSetting : class; +} \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs b/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs index 4487feb..15c51f9 100644 --- a/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs +++ b/NetinaShop.AdminPanel.PWA/Services/RestServices/RestWrapper.cs @@ -32,6 +32,7 @@ public class RestWrapper : IRestWrapper public IPaymentRestApi PaymentRestApi => RestService.For(Address.PaymentController, setting); public IPageRestApi PageRestApi => RestService.For(Address.PageController, setting); public IScraperRestApi ScraperRestApi => RestService.For(Address.ScraperController, setting); - + public ISettingRestApi SettingRestApi => RestService.For(Address.SettingController, setting); public IDashboardApiRest DashboardApiRest => RestService.For(Address.DashboardController, setting); + public IDistrictApiRest DistrictApiRest => RestService.For(Address.DistrictController, setting); } \ No newline at end of file diff --git a/NetinaShop.AdminPanel.PWA/Utilities/Models/CustomEventInterop.cs b/NetinaShop.AdminPanel.PWA/Utilities/Models/CustomEventInterop.cs deleted file mode 100644 index 34939f8..0000000 --- a/NetinaShop.AdminPanel.PWA/Utilities/Models/CustomEventInterop.cs +++ /dev/null @@ -1,37 +0,0 @@ -namespace NetinaShop.AdminPanel.PWA.Utilities.Models; - public class CustomEventHelper - { - private readonly Func _callback; - - public CustomEventHelper(Func callback) - { - _callback = callback; - } - - [JSInvokable] - public Task OnCustomEvent(EventArgs args) => _callback(args); - } - - public class CustomEventInterop : IDisposable - { - private readonly IJSRuntime _jsRuntime; - private DotNetObjectReference Reference; - - public CustomEventInterop(IJSRuntime jsRuntime) - { - _jsRuntime = jsRuntime; - } - - public ValueTask SetupCustomEventCallback(Func callback) - { - Reference = DotNetObjectReference.Create(new CustomEventHelper(callback)); - // addCustomEventListener will be a js function we create later - return _jsRuntime.InvokeAsync("addCustomEventListener", Reference); - } - - public void Dispose() - { - Reference?.Dispose(); - } - } - diff --git a/NetinaShop.AdminPanel.PWA/version.json b/NetinaShop.AdminPanel.PWA/version.json index ea549b0..6f67c2a 100644 --- a/NetinaShop.AdminPanel.PWA/version.json +++ b/NetinaShop.AdminPanel.PWA/version.json @@ -1,6 +1,6 @@ { - "version": "0.17.19.26", - "versionNumber": 0.171926, + "version": "0.19.22.38", + "versionNumber": 0.192238, "versionName": "چرتکه", "description": "", "features": [ @@ -8,10 +8,14 @@ "تکمیل پروسه سفارش گیری", "قابلیت افزودن تصویر به برند ها", "قابلیت افزودن تصویر به دسته بندی محصولات", - "تغییر دیالوگ پرسشی" + "تغییر دیالوگ پرسشی", + "افزودن تنظیمات درگاه", + "افزودن بخش تنظیمات فروشگاه" ], "bugFixes": [ "حل مشکلات امنیتی", - "رفع مشکلات رسپانسیو" + "رفع مشکلات رسپانسیو", + "رفع مشکل دریافت تصاویر", + "رفع مشکل عدم اتصال به درگاه" ] } diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css index ce2720d..d5c5033 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css @@ -1072,6 +1072,10 @@ input:checked + .toggle-bg { margin-left: 2.5rem; margin-right: 2.5rem; } +.mx-2 { + margin-left: 0.5rem; + margin-right: 0.5rem; +} .mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; @@ -1674,6 +1678,10 @@ input:checked + .toggle-bg { padding-top: 0.75rem; padding-bottom: 0.75rem; } +.py-5 { + padding-top: 1.25rem; + padding-bottom: 1.25rem; +} .py-8 { padding-top: 2rem; padding-bottom: 2rem; diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css index e3073a8..79b6e75 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css @@ -1150,6 +1150,11 @@ input:checked + .toggle-bg { margin-right: 2.5rem; } +.mx-2 { + margin-left: 0.5rem; + margin-right: 0.5rem; +} + .mx-3 { margin-left: 0.75rem; margin-right: 0.75rem; @@ -1190,6 +1195,11 @@ input:checked + .toggle-bg { margin-bottom: 1rem; } +.my-5 { + margin-top: 1.25rem; + margin-bottom: 1.25rem; +} + .my-auto { margin-top: auto; margin-bottom: auto; @@ -1932,6 +1942,11 @@ input:checked + .toggle-bg { padding-bottom: 0.75rem; } +.py-5 { + padding-top: 1.25rem; + padding-bottom: 1.25rem; +} + .py-8 { padding-top: 2rem; padding-bottom: 2rem;