From 64a45104452543a6658f6c0b4098d299b90c3b62 Mon Sep 17 00:00:00 2001 From: "Amir.H Khademi" Date: Sat, 13 Apr 2024 22:20:58 +0330 Subject: [PATCH] feat : add delivery tracking code --- .../Components/Originals/SideBarUi.razor | 2 +- .../Dialogs/OrderActionDialogBox.razor | 150 ++++++++++-------- .../Dialogs/OrderActionDialogBox.razor.cs | 46 +++++- .../OrderTrackingCodeActionDialogBox.razor | 38 +++++ .../NetinaShop.AdminPanel.PWA.csproj | 4 +- .../Pages/OrdersPage.razor | 10 +- .../Pages/ProductsPage.razor | 139 ++++++++++------ .../Pages/ShippingPage.razor | 25 +-- .../Pages/UserSettingsPage.razor | 6 +- .../Services/RestServices/IOrderRestApi.cs | 4 +- NetinaShop.AdminPanel.PWA/package-lock.json | 10 +- NetinaShop.AdminPanel.PWA/package.json | 12 +- NetinaShop.AdminPanel.PWA/version.json | 12 +- .../wwwroot/css/app.min.css | 36 ++++- .../wwwroot/css/app.output.css | 44 +++-- 15 files changed, 370 insertions(+), 168 deletions(-) create mode 100644 NetinaShop.AdminPanel.PWA/Dialogs/OrderTrackingCodeActionDialogBox.razor diff --git a/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor b/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor index 4f2a0d1..3a573bf 100644 --- a/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor +++ b/NetinaShop.AdminPanel.PWA/Components/Originals/SideBarUi.razor @@ -71,7 +71,7 @@ فروشگاه - نقش ها و کاربران + نقش ها و کاربران

Version : @version

diff --git a/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor b/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor index 3eaae15..2abe7b0 100644 --- a/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor +++ b/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor @@ -14,11 +14,11 @@ - + - + اطلاعات سفارش - + @ViewModel.PageDto.OrderStatus.ToDisplay() @@ -38,36 +38,40 @@ - + @ViewModel.PageDto?.OrderDelivery?.Address - - @ViewModel.PageDto?.OrderDelivery?.ShippingMethod + + @ViewModel.PageDto?.OrderDelivery?.ShippingMethod + + + + @ViewModel.PageDto?.OrderDelivery?.TrackingCode - + - - کالاهای این سفارش - + + کالاهای این سفارش + - @ViewModel.PageDto.OrderProducts.Sum(op => op.Count) قلم کالا + @ViewModel.PageDto.OrderProducts.Sum(op => op.Count) قلم کالا - - + + - + - - @context.Item.ProductName + + @context.Item.ProductName @@ -99,31 +103,31 @@ جمع کالاها : - + @ViewModel.PageDto.TotalProductsPrice.ToString("N0") ریالــ - + مالیات : - + @ViewModel.PageDto.TaxesPrice.ToString("N0") ریالــ - + بسته بندی : - + @ViewModel.PageDto.PackingPrice.ToString("N0") ریالــ - + هزینه ارسال : - + @ViewModel.PageDto.DeliveryPrice.ToString("N0") ریالــ @@ -135,23 +139,23 @@ جمع کل : - + @ViewModel.PageDto.TotalPriceWithoutDiscount.ToString("N0") ریالــ - + مقدار تخفیف : - + @ViewModel.PageDto.DiscountPrice.ToString("N0") ریالــ - + مبلغ قابل پرداخت : - + @ViewModel.PageDto.TotalPrice.ToString("N0") ریالــ @@ -160,48 +164,60 @@ پرداختــ ها - + - - - @foreach (var item in ViewModel.PageDto.Payments) - { - + + + @foreach (var item in ViewModel.PageDto.Payments) + { + @item.Type.ToDisplay() - - @item.Status.ToDisplay() - - @item.Amount.ToString("N0") ریالــ - - } - - + @item.Status.ToDisplay() + + @item.Amount.ToString("N0") ریالــ + + } + + - - - - - + - - بستن - + + + + + + + + + + + + + + @@ -220,7 +236,7 @@ if (Order == null) ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, PrintingService, JsRuntime); else - ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, Order , PrintingService , JsRuntime); + ViewModel = new OrderActionDialogBoxViewModel(Snackbar, RestWrapper, UserUtility, DialogService, MudDialog, Order, PrintingService, JsRuntime); await ViewModel.InitializeAsync(); await base.OnInitializedAsync(); } diff --git a/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs b/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs index d5f9f18..7a4f468 100644 --- a/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs +++ b/NetinaShop.AdminPanel.PWA/Dialogs/OrderActionDialogBox.razor.cs @@ -54,6 +54,7 @@ public class OrderActionDialogBoxViewModel : BaseViewModel public string ConfirmOrderButtonText { get; set; } = string.Empty; public bool IsEditing = false; + public bool CanConfirm = true; public override async Task InitializeAsync() @@ -88,6 +89,10 @@ public class OrderActionDialogBoxViewModel : BaseViewModel case OrderStatus.Delivered: ConfirmOrderButtonText = "ثبت انجام سفارش"; break; + case OrderStatus.Done: + ConfirmOrderButtonText = "انجام شده"; + CanConfirm = false; + break; default: throw new ArgumentOutOfRangeException(); } @@ -171,6 +176,45 @@ public class OrderActionDialogBoxViewModel : BaseViewModel default: throw new ArgumentOutOfRangeException(); } + + if (nextOrderStatus == OrderStatus.Delivered) + { + var options = new DialogOptions { MaxWidth = MaxWidth.Small, FullWidth = true, NoHeader = true, CloseOnEscapeKey = true }; + var trackingDialog = await _dialogService.ShowAsync("ارسال کد رهگیری پستی", options); + var trackingDialogResult = await trackingDialog.Result; + if (!trackingDialogResult.Canceled && trackingDialogResult.Data is string trackingCode) + { + try + { + var token = await _userUtility.GetBearerTokenAsync(); + if (token == null) + throw new Exception("Token is null"); + IsProcessing = true; + + + await _restWrapper.OrderRestApi.ConfirmOrderStepAsync(PageDto.Id, nextOrderStatus,trackingCode, token); + _snackbar.Add($"سفارش {PageDto.FactorCode} به {nextOrderStatus.ToDisplay()} تغییر یافت", Severity.Success); + _mudDialog.Close(true); + } + catch (ApiException ex) + { + var exe = await ex.GetContentAsAsync(); + _snackbar.Add(exe != null ? exe.Message : ex.Content, Severity.Error); + _mudDialog.Cancel(); + } + catch (Exception e) + { + _snackbar.Add(e.Message, Severity.Error); + _mudDialog.Cancel(); + } + finally + { + + IsProcessing = false; + } + } + return; + } var reference = await _dialogService.ShowQuestionDialog($"آیا از ثبت سفارش به {nextOrderStatus.ToDisplay()} اطمینان دارید ?"); var result = await reference.Result; @@ -187,7 +231,7 @@ public class OrderActionDialogBoxViewModel : BaseViewModel await _restWrapper.OrderRestApi.ConfirmOrderStepAsync(PageDto.Id, nextOrderStatus, token); _snackbar.Add($"سفارش {PageDto.FactorCode} به {nextOrderStatus.ToDisplay()} تغییر یافت", Severity.Success); - _mudDialog.Close(); + _mudDialog.Close(true); } catch (ApiException ex) { diff --git a/NetinaShop.AdminPanel.PWA/Dialogs/OrderTrackingCodeActionDialogBox.razor b/NetinaShop.AdminPanel.PWA/Dialogs/OrderTrackingCodeActionDialogBox.razor new file mode 100644 index 0000000..59c7312 --- /dev/null +++ b/NetinaShop.AdminPanel.PWA/Dialogs/OrderTrackingCodeActionDialogBox.razor @@ -0,0 +1,38 @@ + + + + لطفا کد رهگیری ارسال را وارد کنید + + + + + + + + تایید + + + + انصراف + + + + +@code +{ + + [CascadingParameter] + MudDialogInstance? MudDialog { get; set; } + + public string TrackingCode { get; set; } = string.Empty; + + void Submit() + { + if (TrackingCode.IsNullOrEmpty()) + { + return; + } + MudDialog?.Close(DialogResult.Ok(TrackingCode)); + } + void Cancel() => MudDialog?.Cancel(); +} \ 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 4d74437..117e9ed 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.21.31 - 0.17.21.31 + 0.17.21.32 + 0.17.21.32 $(MSBuildProjectName) diff --git a/NetinaShop.AdminPanel.PWA/Pages/OrdersPage.razor b/NetinaShop.AdminPanel.PWA/Pages/OrdersPage.razor index adf4f52..c8e8419 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/OrdersPage.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/OrdersPage.razor @@ -7,31 +7,31 @@ @inject IUserUtility UserUtility @inject IRestWrapper RestWrapper - + - + سفارشات امروز 1124 عدد - + سفارشات در انتظار تایید 845 عدد - + تغییر نسبت هفته پیش 125 عدد - + تغییر نسبت به ماه پیش 10 diff --git a/NetinaShop.AdminPanel.PWA/Pages/ProductsPage.razor b/NetinaShop.AdminPanel.PWA/Pages/ProductsPage.razor index 0835b02..f92a369 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/ProductsPage.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/ProductsPage.razor @@ -10,23 +10,64 @@ - - محصولاتــــ - 124 عدد - - افزودن محصول - @* افزودن محصول از دیجیکالا *@ - + + + + محصولاتــــ + 124 عدد + + + + افزودن محصول + افزودن محصول از دیجیکالا + + + + + + + + + + + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
+
+
+
- + - - - + + + - - - - - -
- -

منتظر بمانید

-
-
-
-
- -

@e.Name

-
-
-
-
+ + + + + +
+ +

منتظر بمانید

+
+
+
+
+ +

@e.Name

+
+
+
+
diff --git a/NetinaShop.AdminPanel.PWA/Pages/ShippingPage.razor b/NetinaShop.AdminPanel.PWA/Pages/ShippingPage.razor index a6e17ef..20dc672 100644 --- a/NetinaShop.AdminPanel.PWA/Pages/ShippingPage.razor +++ b/NetinaShop.AdminPanel.PWA/Pages/ShippingPage.razor @@ -10,16 +10,21 @@ - - روش های ارسال سفارش - - افزودن روش جدید - + + + + روش های ارسال سفارش + + + + افزودن روش جدید + + افزودن کاربر - + افزودن نقش
- + ReadOne(Guid id, [Header("Authorization")] string authorization); [Post("/{id}/confirm")] - Task ConfirmOrderStepAsync(Guid id,[Query] OrderStatus nextOrderStatus , [Header("Authorization")] string authorization); + Task ConfirmOrderStepAsync(Guid id,[Query] OrderStatus nextOrderStatus, [Header("Authorization")] string authorization); + [Post("/{id}/confirm")] + Task ConfirmOrderStepAsync(Guid id, [Query] OrderStatus nextOrderStatus, [Query]string trackingCode, [Header("Authorization")] string authorization); [Get("/{id}/invoice")] Task GetOrderInvoice(Guid id, [Header("Authorization")] string authorization); diff --git a/NetinaShop.AdminPanel.PWA/package-lock.json b/NetinaShop.AdminPanel.PWA/package-lock.json index 322382e..f22e945 100644 --- a/NetinaShop.AdminPanel.PWA/package-lock.json +++ b/NetinaShop.AdminPanel.PWA/package-lock.json @@ -34,7 +34,7 @@ "flowbite": "^2.2.1", "postcss": "^8.4.33", "postcss-cli": "^11.0.0", - "tailwindcss": "^3.4.1" + "tailwindcss": "^3.4.3" } }, "node_modules/@alloc/quick-lru": { @@ -1802,9 +1802,9 @@ } }, "node_modules/tailwindcss": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz", - "integrity": "sha512-qAYmXRfk3ENzuPBakNK0SRrUDipP8NQnEY6772uDhflcQz5EhRdD7JNZxyrFHVQNCwULPBn6FNPp9brpO7ctcA==", + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.3.tgz", + "integrity": "sha512-U7sxQk/n397Bmx4JHbJx/iSOOv5G+II3f1kpLpY2QeUv5DcPdcTsYLlusZfq1NthHS1c1cZoyFmmkex1rzke0A==", "dependencies": { "@alloc/quick-lru": "^5.2.0", "arg": "^5.0.2", @@ -1814,7 +1814,7 @@ "fast-glob": "^3.3.0", "glob-parent": "^6.0.2", "is-glob": "^4.0.3", - "jiti": "^1.19.1", + "jiti": "^1.21.0", "lilconfig": "^2.1.0", "micromatch": "^4.0.5", "normalize-path": "^3.0.0", diff --git a/NetinaShop.AdminPanel.PWA/package.json b/NetinaShop.AdminPanel.PWA/package.json index e70b4f7..f52e901 100644 --- a/NetinaShop.AdminPanel.PWA/package.json +++ b/NetinaShop.AdminPanel.PWA/package.json @@ -1,10 +1,5 @@ { "dependencies": { - "autoprefixer": "^10.4.17", - "flowbite": "^2.2.1", - "postcss": "^8.4.33", - "postcss-cli": "^11.0.0", - "tailwindcss": "^3.4.1", "@ckeditor/ckeditor5-alignment": "41.0.0", "@ckeditor/ckeditor5-autoformat": "41.0.0", "@ckeditor/ckeditor5-basic-styles": "41.0.0", @@ -25,7 +20,12 @@ "@ckeditor/ckeditor5-typing": "41.0.0", "@ckeditor/ckeditor5-undo": "41.0.0", "@ckeditor/ckeditor5-upload": "41.0.0", - "@ckeditor/ckeditor5-word-count": "41.0.0" + "@ckeditor/ckeditor5-word-count": "41.0.0", + "autoprefixer": "^10.4.17", + "flowbite": "^2.2.1", + "postcss": "^8.4.33", + "postcss-cli": "^11.0.0", + "tailwindcss": "^3.4.3" }, "name": "netina.admin.pwa", "version": "1.0.0", diff --git a/NetinaShop.AdminPanel.PWA/version.json b/NetinaShop.AdminPanel.PWA/version.json index 6f67c2a..d357313 100644 --- a/NetinaShop.AdminPanel.PWA/version.json +++ b/NetinaShop.AdminPanel.PWA/version.json @@ -5,17 +5,19 @@ "description": "", "features": [ "افزودن تم دارک", - "تکمیل پروسه سفارش گیری", - "قابلیت افزودن تصویر به برند ها", - "قابلیت افزودن تصویر به دسته بندی محصولات", "تغییر دیالوگ پرسشی", "افزودن تنظیمات درگاه", - "افزودن بخش تنظیمات فروشگاه" + "افزودن کد رهگیری پستی", + "تکمیل پروسه سفارش گیری", + "افزودن بخش تنظیمات فروشگاه", + "قابلیت افزودن تصویر به برند ها", + "قابلیت افزودن تصویر به دسته بندی محصولات" ], "bugFixes": [ "حل مشکلات امنیتی", "رفع مشکلات رسپانسیو", "رفع مشکل دریافت تصاویر", - "رفع مشکل عدم اتصال به درگاه" + "رفع مشکل عدم اتصال به درگاه", + "رفع مشکلات ساختاری در ریسپانس" ] } diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css index d5c5033..1cda2b9 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.min.css @@ -1,5 +1,5 @@ /* -! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com *//* 1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4) 2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116) @@ -179,6 +179,7 @@ textarea { font-size: 100%; /* 1 */ font-weight: inherit; /* 1 */ line-height: inherit; /* 1 */ + letter-spacing: inherit; /* 1 */ color: inherit; /* 1 */ margin: 0; /* 2 */ padding: 0; /* 3 */ @@ -199,9 +200,9 @@ select { */ button, -[type='button'], -[type='reset'], -[type='submit'] { +input:where([type='button']), +input:where([type='reset']), +input:where([type='submit']) { -webkit-appearance: button; /* 1 */ background-color: transparent; /* 2 */ background-image: none; /* 2 */ @@ -913,6 +914,10 @@ input:checked + .toggle-bg { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } ::backdrop { @@ -963,6 +968,10 @@ input:checked + .toggle-bg { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } .container { width: 100%; @@ -1115,6 +1124,9 @@ input:checked + .toggle-bg { .-mb-3 { margin-bottom: -0.75rem; } +.-mb-4 { + margin-bottom: -1rem; +} .-ml-4 { margin-left: -1rem; } @@ -1293,6 +1305,9 @@ input:checked + .toggle-bg { .min-h-\[33rem\] { min-height: 33rem; } +.min-h-screen { + min-height: 100vh; +} .w-1\/2 { width: 50%; } @@ -2118,6 +2133,19 @@ code { @media (min-width: 768px) { + .md\:visible { + visibility: visible; + } + + .md\:my-auto { + margin-top: auto; + margin-bottom: auto; + } + + .md\:w-auto { + width: auto; + } + .md\:basis-1\/2 { flex-basis: 50%; } diff --git a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css index 79b6e75..a06eacd 100644 --- a/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css +++ b/NetinaShop.AdminPanel.PWA/wwwroot/css/app.output.css @@ -1,5 +1,5 @@ /* -! tailwindcss v3.4.1 | MIT License | https://tailwindcss.com +! tailwindcss v3.4.3 | MIT License | https://tailwindcss.com */ /* @@ -211,6 +211,8 @@ textarea { /* 1 */ line-height: inherit; /* 1 */ + letter-spacing: inherit; + /* 1 */ color: inherit; /* 1 */ margin: 0; @@ -234,9 +236,9 @@ select { */ button, -[type='button'], -[type='reset'], -[type='submit'] { +input:where([type='button']), +input:where([type='reset']), +input:where([type='submit']) { -webkit-appearance: button; /* 1 */ background-color: transparent; @@ -965,6 +967,10 @@ input:checked + .toggle-bg { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } ::backdrop { @@ -1015,6 +1021,10 @@ input:checked + .toggle-bg { --tw-backdrop-opacity: ; --tw-backdrop-saturate: ; --tw-backdrop-sepia: ; + --tw-contain-size: ; + --tw-contain-layout: ; + --tw-contain-paint: ; + --tw-contain-style: ; } .container { @@ -1195,11 +1205,6 @@ 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; @@ -1317,6 +1322,10 @@ input:checked + .toggle-bg { margin-top: 2rem; } +.-mb-4 { + margin-bottom: -1rem; +} + .line-clamp-1 { overflow: hidden; display: -webkit-box; @@ -1445,6 +1454,10 @@ input:checked + .toggle-bg { min-height: 33rem; } +.min-h-screen { + min-height: 100vh; +} + .w-1\/2 { width: 50%; } @@ -2458,6 +2471,19 @@ code { } @media (min-width: 768px) { + .md\:visible { + visibility: visible; + } + + .md\:my-auto { + margin-top: auto; + margin-bottom: auto; + } + + .md\:w-auto { + width: auto; + } + .md\:basis-1\/2 { flex-basis: 50%; }