diff --git a/Wonky.Client.sln.DotSettings b/Wonky.Client.sln.DotSettings index 4ca40c1b..3a5c349c 100644 --- a/Wonky.Client.sln.DotSettings +++ b/Wonky.Client.sln.DotSettings @@ -1,2 +1,3 @@  + True True \ No newline at end of file diff --git a/Wonky.Client/App.razor b/Wonky.Client/App.razor index dcd1dfe9..edc683e8 100644 --- a/Wonky.Client/App.razor +++ b/Wonky.Client/App.razor @@ -36,5 +36,4 @@ - - + \ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor b/Wonky.Client/Components/LandingComponentAdvisor.razor index da919ecc..9f156af2 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor @@ -21,16 +21,9 @@ Inno Web CRM -
-
-
-

@(DateTime.Now.ToLongDateString())

-
-
- -
-
+
+
- - + + \ No newline at end of file diff --git a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs index 4c3db77c..aeeaeb27 100644 --- a/Wonky.Client/Components/LandingComponentAdvisor.razor.cs +++ b/Wonky.Client/Components/LandingComponentAdvisor.razor.cs @@ -46,16 +46,13 @@ public partial class LandingComponentAdvisor : IDisposable }; private Preferences _prefs { get; set; } = new(); - private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; - private string _today { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; + private DateTime SelectedDate { get; set; } private List? _taskItems { get; set; } = new(); - protected override async Task OnInitializedAsync() { _prefs = await _preferenceService.GetPreferences(); - if(!string.IsNullOrWhiteSpace(_prefs.WorkDate)) - _workDate = _prefs.WorkDate; + SelectedDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) ? DateTime.Now : DateTime.Parse(_prefs.WorkDate); _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); @@ -78,9 +75,9 @@ public partial class LandingComponentAdvisor : IDisposable private async Task GetWorkdayTasks(string workDate) { - _workDate = workDate; + SelectedDate = DateTime.Parse(workDate); _taskItems = new List(); - _taskItems = await CrmTaskItemRepo.GetTaskList(workDate); + _taskItems = await CrmTaskItemRepo.GetTaskList($"{SelectedDate:yyyy-MM-dd}"); } private async Task OnTaskCompleted(string taskItemId) diff --git a/Wonky.Client/Components/ProductInventoryTableComponent.razor b/Wonky.Client/Components/ProductInventoryTableComponent.razor index 63881426..0e85ff38 100644 --- a/Wonky.Client/Components/ProductInventoryTableComponent.razor +++ b/Wonky.Client/Components/ProductInventoryTableComponent.razor @@ -48,10 +48,12 @@ @product.Quantity - Linjer + } -} \ No newline at end of file +} + + \ No newline at end of file diff --git a/Wonky.Client/Components/ProductInventoryTableComponent.razor.cs b/Wonky.Client/Components/ProductInventoryTableComponent.razor.cs index e4cb963c..f5ff928a 100644 --- a/Wonky.Client/Components/ProductInventoryTableComponent.razor.cs +++ b/Wonky.Client/Components/ProductInventoryTableComponent.razor.cs @@ -13,7 +13,11 @@ // along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] // +using System.Globalization; using Microsoft.AspNetCore.Components; +using Wonky.Client.HttpInterfaces; +using Wonky.Client.Models; +using Wonky.Client.Shared; using Wonky.Entity.DTO; using Wonky.Entity.Views; @@ -21,6 +25,50 @@ namespace Wonky.Client.Components; public partial class ProductInventoryTableComponent { + [CascadingParameter] DraftStateProvider DraftStateProvider { get; set; } [Parameter] public List Inventory { get; set; } = new(); [Parameter] public string CompanyId { get; set; } = ""; + [Inject] public ICatalogHttpRepository Catalog { get; set; } + + private SalesItemView SalesItem { get; set; } = new(); + private string Price { get; set; } = "0"; + private string Quantity { get; set; } = "1"; + private string Sku { get; set; } = ""; + private InventoryReorderModal ReorderModal { get; set; } = new(); + private SelectedSku Item { get; set; } = new(); + + + private async Task CallShowReorderModal(string sku) + { + SalesItem = await Catalog.GetSalesItemSku(sku); + ReorderModal.Show(); + } + + private async Task OnSelectedItem(DraftItem draftItem) + { + DraftStateProvider.Draft.Items.Add(draftItem); + await DraftStateProvider.SaveChangesAsync(); + } + + // private async Task AddItem(SalesItemView salesItem) + // { + // // create a new cart item + // var item = new DraftItem + // { + // Item = salesItem, + // Quantity = Convert.ToInt32(Quantity), + // Price = Convert.ToDecimal(Price, CultureInfo.InvariantCulture), + // Discount = Convert.ToDecimal(Discount, CultureInfo.InvariantCulture), + // Sas = Sas + // }; + // // reset internals to initial state + // Sas = false; + // Quantity = "1"; + // Price = "0"; + // Discount = "0"; + // // add it to the cart + // DraftStateProvider.Draft.Items.Add(item); + // // save the item using the CartStateProvider's save method + // await DraftStateProvider.SaveChangesAsync(); + // } } \ No newline at end of file diff --git a/Wonky.Client/Components/ReportItemComponent.razor b/Wonky.Client/Components/ReportItemComponent.razor index 29ada42e..105c58ca 100644 --- a/Wonky.Client/Components/ReportItemComponent.razor +++ b/Wonky.Client/Components/ReportItemComponent.razor @@ -41,6 +41,12 @@ + + Vores Ref. + @ReportItem.OurRef + EOrdre + @ReportItem.ESalesNumber + Dato @ReportItem.OrderDate diff --git a/Wonky.Client/Components/ReportSummaryComponent.razor b/Wonky.Client/Components/ReportSummaryComponent.razor index c835468a..ec6d212f 100644 --- a/Wonky.Client/Components/ReportSummaryComponent.razor +++ b/Wonky.Client/Components/ReportSummaryComponent.razor @@ -53,6 +53,9 @@ case "Meeting": Salgsmøde break; + case "Supervisor": + Supervisor + break; default: break; diff --git a/Wonky.Client/Components/ReportTableComponent.razor b/Wonky.Client/Components/ReportTableComponent.razor index bd998ac2..4e7675d6 100644 --- a/Wonky.Client/Components/ReportTableComponent.razor +++ b/Wonky.Client/Components/ReportTableComponent.razor @@ -63,6 +63,9 @@ case "Leave": Ferie break; + case "Supervisor": + Supervisor + break; } }
diff --git a/Wonky.Client/Components/TopbarDisplayUser.razor b/Wonky.Client/Components/TopbarDisplayUser.razor index f6331a3c..ad416007 100644 --- a/Wonky.Client/Components/TopbarDisplayUser.razor +++ b/Wonky.Client/Components/TopbarDisplayUser.razor @@ -22,4 +22,4 @@ @context.User.Identity?.Name -
\ No newline at end of file + diff --git a/Wonky.Client/Components/WorkDateComponent.razor b/Wonky.Client/Components/WorkDateComponent.razor index cfb57014..6dbc50a3 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor +++ b/Wonky.Client/Components/WorkDateComponent.razor @@ -18,5 +18,15 @@ @using Blazored.LocalStorage @using Wonky.Client.Services - + +
+
+
+ @SelectedDate.ToLongDateString() +
+
+ +
+
+
+
\ No newline at end of file diff --git a/Wonky.Client/Components/WorkDateComponent.razor.cs b/Wonky.Client/Components/WorkDateComponent.razor.cs index a328b3dc..b6341c0e 100644 --- a/Wonky.Client/Components/WorkDateComponent.razor.cs +++ b/Wonky.Client/Components/WorkDateComponent.razor.cs @@ -17,6 +17,7 @@ using System.Globalization; using Blazored.LocalStorage; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Forms; using Wonky.Client.Services; namespace Wonky.Client.Components; @@ -27,47 +28,43 @@ public partial class WorkDateComponent : IDisposable /// User preference service /// [Inject] public PreferenceService Prefs { get; set; } - /// /// OnChanged callback function /// - [Parameter] public EventCallback OnChanged { get; set; } - + [Parameter] public EventCallback OnChangedCallback { get; set; } + private EditContext WorkDateContext { get; set; } /// /// Selected data /// - [Parameter] public string SelectedDate { get; set; } = $"{DateOnly.FromDateTime(DateTime.Now):yyyy-MM-dd}"; - + private DateTime SelectedDate { get; set; } /// /// user preferences /// private Preferences _prefs = new(); - /// /// Component Initialization /// protected override async Task OnInitializedAsync() { + WorkDateContext = new EditContext(SelectedDate); Prefs.OnChange += ProfileServiceOnOnChange; _prefs = await Prefs.GetPreferences(); - - if (!string.IsNullOrWhiteSpace(_prefs.WorkDate)) - SelectedDate = _prefs.WorkDate; + SelectedDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) + ? DateTime.Now + : DateTime.Parse(_prefs.WorkDate); } - /// /// OnDateChanged function call to invoke the event callback /// /// private async Task OnDateChanged(ChangeEventArgs e) { - var val = $"{DateOnly.Parse(e.Value?.ToString()!):yyyy-MM-dd}"; - await Prefs.SetWorkDate(DateTime.Parse(val)); - await OnChanged.InvokeAsync(val); + var val = DateTime.Parse(e.Value.ToString()); + await Prefs.SetWorkDate(val); + await OnChangedCallback.InvokeAsync($"{val:yyyy-MM-dd}"); } - /// - /// + /// ProfileService /// /// private void ProfileServiceOnOnChange(Preferences newPreferences) @@ -75,7 +72,6 @@ public partial class WorkDateComponent : IDisposable _prefs = newPreferences; StateHasChanged(); } - /// /// Component dispose /// diff --git a/Wonky.Client/Components/WorkDateComponent.razor.css b/Wonky.Client/Components/WorkDateComponent.razor.css new file mode 100644 index 00000000..3a481224 --- /dev/null +++ b/Wonky.Client/Components/WorkDateComponent.razor.css @@ -0,0 +1,7 @@ +.work-date { + font-size: 1.2rem; + font-variant: all-small-caps; +} +.calendar { + min-width: 250px; +} diff --git a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs index 9ba4e9e0..ca991aa6 100644 --- a/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs +++ b/Wonky.Client/HttpInterfaces/ICatalogHttpRepository.cs @@ -24,4 +24,6 @@ public interface ICatalogHttpRepository Task> GetSalesItemsPaged(CatalogPagingParams pagingParameters); Task GetSalesItemId(string salesItemId); Task GetSalesVariantId(string variantId); + Task GetSalesItemSku(string sku); + Task GetSalesItemSku(string countryCode, string sku); } \ No newline at end of file diff --git a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs index 49a88a2e..cc4ca443 100644 --- a/Wonky.Client/HttpRepository/CatalogHttpRepository.cs +++ b/Wonky.Client/HttpRepository/CatalogHttpRepository.cs @@ -91,4 +91,15 @@ public class CatalogHttpRepository : ICatalogHttpRepository .GetFromJsonAsync($"{_apiConfig.Catalog}/variant/{variantId}"); return salesItem ?? new SalesItemView(); } + + public async Task GetSalesItemSku(string sku) + { + var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/sku/{sku}"); + return salesItem ?? new SalesItemView(); + } + public async Task GetSalesItemSku(string countryCode, string sku) + { + var salesItem = await _client.GetFromJsonAsync($"{_apiConfig.Catalog}/{countryCode}/sku/{sku}"); + return salesItem ?? new SalesItemView(); + } } \ No newline at end of file diff --git a/Wonky.Client/Models/Draft.cs b/Wonky.Client/Models/Draft.cs index 677053df..d1862dd8 100644 --- a/Wonky.Client/Models/Draft.cs +++ b/Wonky.Client/Models/Draft.cs @@ -30,6 +30,7 @@ public class DraftItem public class Draft { + public string DraftId { get; set; } = ""; public List Items { get; set; } = new (); public decimal Total { diff --git a/Wonky.Client/Pages/CrmActivityNewPage.razor b/Wonky.Client/Pages/CrmActivityNewPage.razor index 17014abe..da7f9a35 100644 --- a/Wonky.Client/Pages/CrmActivityNewPage.razor +++ b/Wonky.Client/Pages/CrmActivityNewPage.razor @@ -20,60 +20,60 @@ @attribute [Authorize(Roles = "Advisor")] @using Wonky.Client.Components - - - - -
-
-

@_workDate.ToLongDateString()

-
-
- +
+
+
-

@_activity.Name - @_activity.Account

+

@Activity.Name - @Activity.Account

-@if (_reportClosed) +@if (ReportClosed) { -
Der kan ikke oprettes besøg når der findes rapport for @_workDate.ToShortDateString()
+
Der kan ikke oprettes besøg når der findes rapport for @SelectedDate.ToShortDateString()
} else { - +
- + - +
- - - @if (!string.IsNullOrEmpty(_activity.VatNumber) && !string.IsNullOrWhiteSpace(_activity.Address1) && _company.HasFolded == 0) + + + @if (!string.IsNullOrEmpty(Activity.VatNumber) && !string.IsNullOrWhiteSpace(Activity.Address1) && Company.HasFolded == 0) { - + @if (DraftStateProvider.Draft.Items.Any()) + { + + } + else + { + + } } - - @if (_activity.ActivityStatusEnum == "order") + + @if (Activity.ActivityStatusEnum == "order") {
- +
} @@ -83,63 +83,178 @@ else
- - + +
- - + +
- - + +
- - + +
- - + +
- - + +
-
+
- - + +
- - + +
- +
+ @* Order lines -----------------------------------------------------*@ +
+
+ + + + + + + + + + + + + + + + + + + @if (DraftStateProvider.Draft.Items.Count > 0) + { + @foreach (var cartItem in DraftStateProvider.Draft.Items) + { + + + + + + + + + + + } + } + + + + + + + + +
+ Ordrekladde Global kladde (udløber efter @(DraftStateProvider.Draft.TimeToLiveInSeconds / 60)m inaktivitet) + + +
NavnVarenrAntalEnhedspris%LinjesumSAS
@cartItem.Item.Name@cartItem.Item.Sku@cartItem.Quantity@($"{cartItem.Price:N2}")@($"{cartItem.Discount:N2}")@($"{cartItem.LineTotal:N2}") + + + +
Total@($"{DraftStateProvider.Draft.Total:N2}") + +
+
+
+ @* draft line ----------------------------------------------------- *@ +
+
+ @if (!string.IsNullOrWhiteSpace(SelectedItem.Name) && ShowItem) + { + + + + + + + + + + + + + + + + + + + + + + + + +
Kladdelinje
AntalPrisRabatSASVarenr.
+ + +
+ + + @* + + *@ +
+
+ + + + @SelectedItem.Sku + +
+ } +
+
+
- @* Order lines *@ -
+ @* + $1$ Order lines #1# +

+ *@ @* Delivery address *@ -
+

@@ -313,12 +319,15 @@ else Til Oversigt
- +
} - \ No newline at end of file + + + + \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmActivityNewPage.razor.cs b/Wonky.Client/Pages/CrmActivityNewPage.razor.cs index d229a01e..949659b6 100644 --- a/Wonky.Client/Pages/CrmActivityNewPage.razor.cs +++ b/Wonky.Client/Pages/CrmActivityNewPage.razor.cs @@ -38,7 +38,7 @@ public partial class CrmActivityNewPage : IDisposable // Services [Inject] public ILogger Logger { get; set; } [Inject] public HttpInterceptorService Interceptor { get; set; } - [Inject] public PreferenceService PreferenceService { get; set; } + [Inject] public PreferenceService Prefs { get; set; } [Inject] public IToastService Toast { get; set; } [Inject] public NavigationManager Navigator { get; set; } [Inject] public ILocalStorageService Storage { get; set; } @@ -47,13 +47,13 @@ public partial class CrmActivityNewPage : IDisposable [Inject] public ICrmActivityHttpRepository CrmActivityRepo { get; set; } [Inject] public ICrmReportHttpRepository CrmReportRepo { get; set; } // variables - private readonly JsonSerializerOptions? _options = new JsonSerializerOptions{PropertyNameCaseInsensitive = true}; - private SalesItemView _selectedItem { get; set; } = new(); - private Preferences _prefs { get; set; } = new(); - private ActivityDto _activity { get; set; } = new(); - private CompanyDto _company = new(); - private EditContext _editContext { get; set; } - private bool _poFormInvalid { get; set; } = true; + private readonly JsonSerializerOptions? _options = new() {PropertyNameCaseInsensitive = true}; + private SalesItemView SelectedItem { get; set; } = new(); + private Preferences UserPrefs { get; set; } = new(); + private ActivityDto Activity { get; set; } = new(); + private CompanyDto Company = new(); + private EditContext ActivityContext { get; set; } + private bool PoFormInvalid { get; set; } = true; private bool ShowItem { get; set; } private string Quantity = "1"; private string Price = "0"; @@ -64,129 +64,131 @@ public partial class CrmActivityNewPage : IDisposable private bool InvalidActivity = true; private bool InvalidCanvas = true; private bool NoHistory = true; - private bool _reportClosed { get; set; } - private UserInfoView _ux { get; set; } = new(); - private DateTime _workDate { get; set; } = DateTime.Now; - private string _selectedDate { get; set; } = ""; - private string _phone { get; set; } = ""; - private string _confirmDatePrompt { get; set; } + private bool ReportClosed { get; set; } + private UserInfoView ThisUserInfo { get; set; } = new(); + private DateTime SelectedDate { get; set; } + private string OldPhone { get; set; } = ""; + private string PromptDateConfirm { get; set; } // MODAL DIALOGS private PriceListModal PriceListModal { get; set; } private ProductHistoryModal HistoryModal { get; set; } private ProductPriceHistoryModal PriceHistoryModal { get; set; } - private ConfirmationModal ConfirmWorkDate { get; set; } = new(); + private ConfirmWorkDateModal ConfirmWorkDate { get; set; } = new(); - protected override async Task OnParametersSetAsync() - { - Interceptor.RegisterEvent(); - Interceptor.RegisterBeforeSendEvent(); - - _prefs = await PreferenceService.GetPreferences(); - - if (!string.IsNullOrWhiteSpace(_prefs.WorkDate)) - _workDate = DateTime.Parse(_prefs.WorkDate); - _selectedDate = $"{_workDate:yyyy-MM-dd}"; - - // raise flag if report is closed - _reportClosed = await CrmReportRepo.ReportExist(_selectedDate); - } - protected override async Task OnInitializedAsync() { - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - - _activity.ActivityDate = $"{_workDate:yyyy-MM-dd}" ; - - _ux = await Storage.GetItemAsync("_xu"); - - // get company - _company = await CompanyRepo.GetCompanyById(CompanyId); - + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; + + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + // User Preferences + UserPrefs = await Prefs.GetPreferences(); + // User Info + ThisUserInfo = await Storage.GetItemAsync("_xu"); + // Fetch Customer from http + Company = await CompanyRepo.GetCompanyById(CompanyId); + if (Company.HasFolded == 1) + // Company has shutdown activities + Activity.OrderMessage = "BEMÆRK: CVR nummer er ophørt."; // variable to validate if customer needs phone number update - _phone = _company.Phone; - if (string.IsNullOrWhiteSpace(_company.Phone) - && !string.IsNullOrWhiteSpace(_company.Account) - && _company.Account != "NY" && _company.Account.Length > 7) + OldPhone = Company.Phone; + if (string.IsNullOrWhiteSpace(Company.Phone) + && !string.IsNullOrWhiteSpace(Company.Account) + && Company.Account != "NY" && Company.Account.Length > 7) { - _company.Phone = _company.Account[..8]; + Company.Phone = Company.Account[..8]; } - - _activity.BcId = _company.BcId; - _activity.ActivityStatusEnum = "noSale"; - _activity.VisitTypeEnum = _company.Account is "" or "NY" ? "new" : "recall"; - - if (_company.HasFolded == 1) - _activity.OrderMessage = "Virksomheden er ophørt."; - - // permanent identifications - _activity.CompanyId = _company.CompanyId; - _activity.SalesRepId = _ux.Id; - _activity.SalesRep = _ux.Advisor; - _activity.CountryCode = _ux.CountryCode; - - _activity.Account = _company.Account; - _activity.VatNumber = _company.VatNumber; - _activity.Email = _company.Email; - _activity.Phone = _company.Phone; - _activity.Mobile = _company.Mobile; - - _activity.Name = _company.Name; - _activity.Address1 = _company.Address1; - _activity.Address2 = _company.Address2; - _activity.ZipCode = _company.ZipCode; - _activity.City = _company.City; - - _activity.DlvName = _company.Name; - _activity.DlvAddress1 = _company.Address1; - _activity.DlvAddress2 = _company.Address2; - _activity.DlvZipCode = _company.ZipCode; - _activity.DlvCity = _company.City; + // Populate base activity information + Activity.BcId = Company.BcId; + Activity.ActivityStatusEnum = "noSale"; + Activity.VisitTypeEnum = Company.Account is "" or "NY" ? "new" : "recall"; + Activity.CompanyId = Company.CompanyId; + Activity.SalesRepId = ThisUserInfo.Id; + Activity.SalesRep = ThisUserInfo.Advisor; + Activity.CountryCode = ThisUserInfo.CountryCode; + Activity.Account = Company.Account; + Activity.VatNumber = Company.VatNumber; + Activity.Email = Company.Email; + Activity.Phone = Company.Phone; + Activity.Mobile = Company.Mobile; + Activity.Name = Company.Name; + Activity.Address1 = Company.Address1; + Activity.Address2 = Company.Address2; + Activity.ZipCode = Company.ZipCode; + Activity.City = Company.City; + Activity.DlvName = Company.Name; + Activity.DlvAddress1 = Company.Address1; + Activity.DlvAddress2 = Company.Address2; + Activity.DlvZipCode = Company.ZipCode; + Activity.DlvCity = Company.City; + // Initialize date variable + SelectedDate = string.IsNullOrWhiteSpace(UserPrefs.WorkDate) ? DateTime.Now : DateTime.Parse(UserPrefs.WorkDate); + // raise flag if report is closed + ReportClosed = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + // Ask for confirmation of date + Logger.LogDebug("Preferences.DateConfirmed => {}", UserPrefs.DateConfirmed); + if (!UserPrefs.DateConfirmed) + { + PromptDateConfirm = $"Aktiviteter oprettes med dato {SelectedDate.ToShortDateString()}. Er dette OK?"; + ConfirmWorkDate.Show(); + } + // Lines may already have been added from the company inventory page + if (DraftStateProvider.Draft.Items.Any()) + { + // set dropdown selection accordingly + Activity.ActivityTypeEnum = "onSite"; + Activity.ActivityStatusEnum = "order"; + } + StateHasChanged(); } - + /// + /// Work Date confirm callback + /// + private async Task WorkDateConfirmCallback() + { + await Prefs.SetDateConfirmed(true); + ConfirmWorkDate.Hide(); + StateHasChanged(); + } + /// + /// Show Price list modal + /// private void CallPriceListModal() { PriceListModal.Show(); } - - private void VerifyWorkDateConfirmed() - { - Logger.LogDebug("Preferences.DateConfirmed => {}", _prefs.DateConfirmed); - - if (_prefs.DateConfirmed) return; - - _confirmDatePrompt = $"Dato {_activity.ActivityDate}?"; - ConfirmWorkDate.Show(); - } - - private async Task WorkDateConfirmed() - { - await PreferenceService.SetDateConfirmed(true); - ConfirmWorkDate.Hide(); - } - - private async Task SelectSku(SelectedSku sku) + /// + /// Price List modal callback + /// + /// + private async Task PriceListCallback(SelectedSku sku) { // get selected item if (string.IsNullOrWhiteSpace(sku.ItemId)) return; - _selectedItem = await Catalog.GetSalesItemId(sku.ItemId); + SelectedItem = await Catalog.GetSalesItemId(sku.ItemId); ShowItem = true; Price = sku.Rate; Quantity = sku.Quantity; StateHasChanged(); } - + /// + /// Show Price History modal + /// private void CallPriceHistoryModal() { if(ShowItem) PriceHistoryModal.Show(); } - - private void SelectPrice(decimal price) + /// + /// Price History modal callback + /// + /// + private void PriceHistoryCallback(decimal price) { if (price == 0) return; @@ -194,31 +196,30 @@ public partial class CrmActivityNewPage : IDisposable Price = price.ToString("N2", CultureInfo.InvariantCulture); StateHasChanged(); } - - private async Task SetWorkDate(string workDate) + + /// + /// Work Date component callback + /// + /// + private async Task WorkDateComponentCallback(string workDate) { - _selectedDate = workDate; - _workDate = DateTime.Parse(_selectedDate); - _activity.ActivityDate = _selectedDate; - _reportClosed = await CrmReportRepo.ReportExist(_selectedDate); + ReportClosed = await CrmReportRepo.ReportExist(workDate); + SelectedDate = DateTime.Parse(workDate); + Activity.ActivityDate = workDate; } - + /// + /// Validate and Create Activity + /// private async Task CreateActivity() { - - // if (!_prefs.DateConfirmed) - // { - // _confirmDatePrompt = $"Er arbejdsdato {_selectedDate} korrekt?"; - // CallConfirmWorkDate(); - // } - - if (string.IsNullOrWhiteSpace(_activity.Address1)) + + if (string.IsNullOrWhiteSpace(Activity.Address1)) { Toast.ShowError("Kunde adresse er ufuldstændig."); return; } - if (_activity.ActivityStatusEnum == "order") + if (Activity.ActivityStatusEnum == "order") { if (DraftStateProvider.Draft.Items.Count == 0) { @@ -226,27 +227,36 @@ public partial class CrmActivityNewPage : IDisposable return; } - if (string.IsNullOrWhiteSpace(_activity.Phone)) + if (string.IsNullOrWhiteSpace(Activity.Phone)) { Toast.ShowError("Ved bestilling til ny kunde skal telefon nummer angives."); return; - } } - _poFormInvalid = true; - - _activity.ActivityDate = $"{_workDate:yyyy-MM-dd}"; - _activity.OurRef = _activity.ActivityTypeEnum switch + PoFormInvalid = true; + // reset selected item + SelectedItem = new SalesItemView(); + // check if phone number need to be updated + if (OldPhone != Activity.Phone) { - "phone" => $"T:{_ux.FullName.Split(" ")[0]}", - "onSite" => $"B:{_ux.FullName.Split(" ")[0]}", + Company.Phone = Activity.Phone; + // update company phone record + Logger.LogDebug("CrmNewActivityPage => \n New Phone Number \n {}", Activity.Phone); + await CompanyRepo.UpdateCompany(Company.CompanyId, Company); + } + // begin assembling activity + Activity.ActivityDate = $"{SelectedDate:yyyy-MM-dd}"; + Activity.OurRef = Activity.ActivityTypeEnum switch + { + "phone" => $"T:{ThisUserInfo.FullName.Split(" ")[0]}", + "onSite" => $"B:{ThisUserInfo.FullName.Split(" ")[0]}", _ => "" }; - if (_activity.Express) - _activity.OurRef = $"E{_activity.OurRef}"; - - _activity.Lines = new List(); + if (Activity.Express) + Activity.OurRef = $"E{Activity.OurRef}"; + // begin lines + Activity.Lines = new List(); var ln = 0; if (DraftStateProvider.Draft.Items.Count != 0) { @@ -264,22 +274,12 @@ public partial class CrmActivityNewPage : IDisposable Location = item.Item.Location }) .ToList(); - _activity.Lines = lines; + Activity.Lines = lines; } - if (_phone != _activity.Phone) - { - _company.Phone = _activity.Phone; - // update company phone record - await CompanyRepo.UpdateCompany(_company.CompanyId, _company); - } - - Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(_activity)); - + Logger.LogDebug("CrmNewActivityPage => \n {}", JsonSerializer.Serialize(Activity)); // post to api - var result = await CrmActivityRepo.CreateActivity(_activity); - + var result = await CrmActivityRepo.CreateActivity(Activity); Logger.LogDebug("ApiResponseView => \n {}", JsonSerializer.Serialize(result)); - // show result message if (result.IsSuccess) { @@ -289,21 +289,20 @@ public partial class CrmActivityNewPage : IDisposable return; } - _poFormInvalid = false; + PoFormInvalid = false; Toast.ShowError(result.Message, "ORDRE FEJL"); - _selectedItem = new SalesItemView(); } - - private void CheckActivity() - { - InvalidActivityType = string.IsNullOrWhiteSpace(_activity.ActivityTypeEnum); - } - + /// + /// Delete current draft + /// private async Task DeleteDraft() { await DraftStateProvider.DeleteDraftAsync(); } - + /// + /// Add item to draft + /// + /// private async Task AddItem(SalesItemView salesItem) { ShowItem = false; @@ -326,6 +325,10 @@ public partial class CrmActivityNewPage : IDisposable // save the item using the CartStateProvider's save method await DraftStateProvider.SaveChangesAsync(); } + /// + /// Remove item from draft + /// + /// private async Task RemoveItem(DraftItem item) { // remove item @@ -333,53 +336,57 @@ public partial class CrmActivityNewPage : IDisposable // save the remaining draft await DraftStateProvider.SaveChangesAsync(); } - + /// + /// Edit Context handle field change + /// + /// + /// private void HandleFieldChanged(object sender, FieldChangedEventArgs e) { // InvalidCanvas = InvalidActivityType; InvalidActivity = InvalidActivityType - || _poFormInvalid + || PoFormInvalid || DraftStateProvider.Draft.Items.Count == 0 - || (_activity.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(_activity.Email)); - if (_activity.YourRef.Length > 35 || _activity.ReferenceNumber.Length > 20) + || (Activity.ActivityStatusEnum == "offer" && string.IsNullOrWhiteSpace(Activity.Email)); + if (Activity.YourRef.Length > 35 || Activity.ReferenceNumber.Length > 20) { - _poFormInvalid = true; + PoFormInvalid = true; return; } - if (InvalidActivity) { - _poFormInvalid = true; + PoFormInvalid = true; return; } - - _poFormInvalid = !_editContext.Validate(); + PoFormInvalid = !ActivityContext.Validate(); StateHasChanged(); } + /// + /// Edit Context handle validation change + /// + /// + /// private void ValidationChanged(object sender, ValidationStateChangedEventArgs e) { - if (string.IsNullOrEmpty(_activity.ActivityTypeEnum) && !_reportClosed) + if (string.IsNullOrEmpty(Activity.ActivityTypeEnum) && !ReportClosed) { Toast.ShowWarning("Aktivitet type kan ikke være tom"); return; } - - _poFormInvalid = false; - - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; - _editContext = new EditContext(_activity); - _editContext.OnFieldChanged += HandleFieldChanged; - _editContext.OnValidationStateChanged += ValidationChanged; - - VerifyWorkDateConfirmed(); + PoFormInvalid = false; + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; + ActivityContext = new EditContext(Activity); + ActivityContext.OnFieldChanged += HandleFieldChanged; + ActivityContext.OnValidationStateChanged += ValidationChanged; } - + /// + /// Implement Dispose from IDisposable + /// public void Dispose() { Interceptor.DisposeEvent(); - _editContext.OnFieldChanged -= HandleFieldChanged; - _editContext.OnValidationStateChanged -= ValidationChanged; + ActivityContext.OnFieldChanged -= HandleFieldChanged; + ActivityContext.OnValidationStateChanged -= ValidationChanged; } - } \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmActivityTodayPage.razor b/Wonky.Client/Pages/CrmActivityTodayPage.razor index c83ae66f..3b9f8067 100644 --- a/Wonky.Client/Pages/CrmActivityTodayPage.razor +++ b/Wonky.Client/Pages/CrmActivityTodayPage.razor @@ -20,12 +20,9 @@ @attribute [Authorize(Roles = "Advisor")] @page "/activity-today" -
-
-

@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")

-
-
- +
+
+
@@ -33,7 +30,7 @@
@if (_reportExist) { - RAPPORT + RAPPORT } else { diff --git a/Wonky.Client/Pages/CrmActivityTodayPage.razor.cs b/Wonky.Client/Pages/CrmActivityTodayPage.razor.cs index e2f79cd4..10d55cf0 100644 --- a/Wonky.Client/Pages/CrmActivityTodayPage.razor.cs +++ b/Wonky.Client/Pages/CrmActivityTodayPage.razor.cs @@ -36,30 +36,28 @@ public partial class CrmActivityTodayPage : IDisposable [Inject] public IToastService _toast { get; set; } private ReportStatusView? ReportStatusView { get; set; } = new(); private Preferences _prefs { get; set; } = new(); - private string _workDate { get; set; } = $"{DateTime.Now:yyyy-MM-dd}"; + private DateTime SelectedDate { get; set; } private bool _reportExist = false; private bool Loading { get; set; } = true; protected override async Task OnInitializedAsync() { _prefs = await _preferenceService.GetPreferences(); - if(!string.IsNullOrWhiteSpace(_prefs.WorkDate)) - _workDate = _prefs.WorkDate; + SelectedDate = string.IsNullOrWhiteSpace(_prefs.WorkDate) ? DateTime.Now : DateTime.Parse(_prefs.WorkDate); _interceptor.RegisterEvent(); _interceptor.RegisterBeforeSendEvent(); - _reportExist = await CrmReportRepo.ReportExist(_workDate); - - await GetActivities(_workDate); + _reportExist = await CrmReportRepo.ReportExist($"{SelectedDate:yyyy-MM-dd}"); + await GetActivities($"{SelectedDate:yyyy-MM-dd}"); } private async Task GetActivities(string workDate) { _toast.ShowInfo("Vent nogle sekunder for data"); - _workDate = workDate; + SelectedDate = DateTime.Parse(workDate); ReportStatusView = new ReportStatusView(); - ReportStatusView = await CrmActivityRepo.GetActivities(workDate); + ReportStatusView = await CrmActivityRepo.GetActivities($"{SelectedDate:yyyy-MM-dd}"); _logger.LogDebug("Activities => {}", JsonSerializer.Serialize(ReportStatusView)); Loading = false; } diff --git a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor index 65a79c0c..e03fd8d4 100644 --- a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor +++ b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor @@ -19,23 +19,21 @@ @using Microsoft.AspNetCore.Authorization @page "/companies/{CompanyId}/h/i" @attribute [Authorize(Roles = "Advisor")] - -
-
-
-
-

@_company.Name

-
-
- Kundekort -
-
- - -
+@if (!Loading) +{ +
+
+

@Company.Name

+
+
-
- -
-
\ No newline at end of file + +} +@if (Loading) +{ + +} + diff --git a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs index a83ea333..b3c27390 100644 --- a/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs +++ b/Wonky.Client/Pages/CrmCompanyInventoryPage.razor.cs @@ -28,39 +28,39 @@ public partial class CrmCompanyInventoryPage : IDisposable { [Parameter] public string CompanyId { get; set; } = ""; [Inject] public ICrmHistoryHttpRepository CrmHistoryRepo { get; set; } - [Inject] public ICrmCompanyHttpRepository _companyRepo { get; set; } - [Inject] public HttpInterceptorService _interceptor { get; set; } - [Inject] public IToastService _toast { get; set; } - private CompanyDto _company { get; set; } = new(); - private List _inventory { get; set; } = new(); - private string _btnUpdateText { get; set; } = "check"; - private bool _working { get; set; } + [Inject] public ICrmCompanyHttpRepository CompanyRepo { get; set; } + [Inject] public HttpInterceptorService Interceptor { get; set; } + [Inject] public IToastService Toaster { get; set; } + private CompanyDto Company { get; set; } = new(); + private List Inventory { get; set; } = new(); + private bool Loading { get; set; } = true; protected override async Task OnInitializedAsync() { - Console.WriteLine($"CompanyId => {CompanyId}"); - _interceptor.RegisterEvent(); - _interceptor.RegisterBeforeSendEvent(); - _company = await _companyRepo.GetCompanyById(CompanyId); - _inventory = await CrmHistoryRepo.FetchInventory(CompanyId); - _inventory = _inventory.OrderBy(x => x.Description).ToList(); + Interceptor.RegisterEvent(); + Interceptor.RegisterBeforeSendEvent(); + Company = await CompanyRepo.GetCompanyById(CompanyId); + var ts = await CrmHistoryRepo.UpdateProductHistory(Company.CompanyId, $"{DateTime.Parse(Company.HistorySync):yyyy-MM-dd}");; + Inventory = await CrmHistoryRepo.FetchInventory(CompanyId); + Inventory = Inventory.OrderBy(x => x.Description).ToList(); + Loading = false; } - - private async Task RefreshHistory() - { - _working = true; - _btnUpdateText = "vent venligst ..."; - _toast.ShowInfo("Vent mens data checkes ..."); - var ts = await CrmHistoryRepo.UpdateProductHistory(_company.CompanyId, $"{DateTime.Parse(_company.HistorySync):yyyy-MM-dd}");; - _company.HistorySync = ts.Replace("\"", ""); - _btnUpdateText = "check"; - _inventory = await CrmHistoryRepo.FetchInventory(CompanyId); - _inventory = _inventory.OrderBy(x => x.Description).ToList(); - _working = false; - - } + + // private async Task RefreshHistory() + // { + // _working = true; + // _btnUpdateText = "vent venligst ..."; + // _toast.ShowInfo("Vent mens data checkes ..."); + // var ts = await CrmHistoryRepo.UpdateProductHistory(_company.CompanyId, $"{DateTime.Parse(_company.HistorySync):yyyy-MM-dd}");; + // _company.HistorySync = ts.Replace("\"", ""); + // _btnUpdateText = "check"; + // _inventory = await CrmHistoryRepo.FetchInventory(CompanyId); + // _inventory = _inventory.OrderBy(x => x.Description).ToList(); + // _working = false; + // } + public void Dispose() { - _interceptor.DisposeEvent(); + Interceptor.DisposeEvent(); } } \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmReportNewPage.razor b/Wonky.Client/Pages/CrmReportNewPage.razor index e1f07a3f..6982dc88 100644 --- a/Wonky.Client/Pages/CrmReportNewPage.razor +++ b/Wonky.Client/Pages/CrmReportNewPage.razor @@ -20,25 +20,19 @@ @attribute [Authorize(Roles = "Advisor")] @page "/sales-reports/new" - -
-
-
-
-

@(_workDate.ToLongDateString())

-
-
- -
-
- @if (_working) - { - - } -
+
+
+ +
+
+ @if (_working) + { + + }
-
+ +
@@ -100,167 +94,188 @@
-
-@if (!_report.DayTypeEnum.ToLower().Contains("leave")) -{ - - - - - - - - - - - - - -
TekstMedkørende Supervisor
- - - - - - -
- - - - - - - - - - - - - - - -
Km aftenKm morgenKm privat
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Dagens Demo @(_report.Figures.NewDemoCount + _report.Figures.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@_report.Figures.NewVisitCount@_report.Figures.NewDemoCount@_report.Figures.NewSaleCount@_report.Figures.NewTurnover@_report.Figures.NewVisitCountMonth@_report.Figures.NewDemoCountMonth@_report.Figures.NewSaleCountMonth@_report.Figures.NewTurnoverMonth
R@_report.Figures.RecallVisitCount@_report.Figures.RecallDemoCount@_report.Figures.RecallSaleCount@_report.Figures.RecallTurnover@_report.Figures.RecallVisitCountMonth@_report.Figures.RecallDemoCountMonth@_report.Figures.RecallSaleCountMonth@_report.Figures.RecallTurnoverMonth
SAS@_report.Figures.SasCount@_report.Figures.SasTurnover@_report.Figures.SasCountMonth@_report.Figures.SasTurnoverMonth
TOTAL@_report.Figures.TotalVisitCount@_report.Figures.TotalDemoCount@_report.Figures.TotalSaleCount@_report.Figures.TotalTurnover@_report.Figures.TotalVisitCountMonth@_report.Figures.TotalDemoCountMonth@_report.Figures.TotalSaleCountMonth@_report.Figures.TotalTurnoverMonth
- - @if (_activities != null) + @if (!_report.DayTypeEnum.ToLower().Contains("leave")) { - - - - - - - - - - - + + + - @foreach (var activity in _activities) - { - - - - - - - - - - - - - } - - - - + +
KundeBynavnDemoSalgNotesasBeløb
TekstMedkørende Supervisor
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}")@if(activity.OurRef.Contains("T:")){ }@if(activity.Express){ }@if(activity.StatusTypeEnum == "Quote"){ }
Total@_activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount) + + + + + + +
+ + + + + + + + + + + + + + + + +
Km aftenKm morgenKm privat
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Dagens Demo @(_report.Figures.NewDemoCount + _report.Figures.RecallDemoCount)Dagens ResultatMåneds Resultat
BesøgDemoSalgBeløbBesøgDemoSalgBeløb
N@_report.Figures.NewVisitCount@_report.Figures.NewDemoCount@_report.Figures.NewSaleCount@_report.Figures.NewTurnover@_report.Figures.NewVisitCountMonth@_report.Figures.NewDemoCountMonth@_report.Figures.NewSaleCountMonth@_report.Figures.NewTurnoverMonth
R@_report.Figures.RecallVisitCount@_report.Figures.RecallDemoCount@_report.Figures.RecallSaleCount@_report.Figures.RecallTurnover@_report.Figures.RecallVisitCountMonth@_report.Figures.RecallDemoCountMonth@_report.Figures.RecallSaleCountMonth@_report.Figures.RecallTurnoverMonth
SAS@_report.Figures.SasCount@_report.Figures.SasTurnover@_report.Figures.SasCountMonth@_report.Figures.SasTurnoverMonth
TOTAL@_report.Figures.TotalVisitCount@_report.Figures.TotalDemoCount@_report.Figures.TotalSaleCount@_report.Figures.TotalTurnover@_report.Figures.TotalVisitCountMonth@_report.Figures.TotalDemoCountMonth@_report.Figures.TotalSaleCountMonth@_report.Figures.TotalTurnoverMonth
+ + @if (_activities != null) + { + + + + + + + + + + + + + + + + + @foreach (var activity in _activities) + { + + + + + + + + + + + + + } + + + + + + + +
KundeBynavnDemoSalgNotesasBeløb + + + + + +
@activity.Company.Name@activity.Company.City@activity.Demo@activity.Sales@activity.OfficeNote@($"{activity.SasAmount:N2}")@(activity.StatusTypeEnum.Contains("Quote") ? $"{0:N2}" : $"{activity.OrderAmount:N2}") + @if (activity.OurRef.Contains("T:")) + { + + } + + @if (activity.Express) + { + + } + + @if (activity.StatusTypeEnum == "Quote") + { + + } +
Total@_activities.Where(x => x.StatusTypeEnum != "Quote").Sum(x => x.OrderAmount)
+ } } -} -
- + \ No newline at end of file diff --git a/Wonky.Client/Pages/CrmReportViewPage.razor b/Wonky.Client/Pages/CrmReportViewPage.razor index 291fa24c..991541b3 100644 --- a/Wonky.Client/Pages/CrmReportViewPage.razor +++ b/Wonky.Client/Pages/CrmReportViewPage.razor @@ -21,17 +21,15 @@ @attribute [Authorize(Roles = "Advisor,Admin,Supervisor")]
-
-
-

@DateTime.Parse(ReportDate).ToLongDateString()

+ +
+
+
-
- -
-
+
-
+
@if (!string.IsNullOrWhiteSpace(_report.ReportData.DayTypeEnum)) { diff --git a/Wonky.Client/Pages/CrmReportViewPage.razor.cs b/Wonky.Client/Pages/CrmReportViewPage.razor.cs index 7afe25de..fb5816b5 100644 --- a/Wonky.Client/Pages/CrmReportViewPage.razor.cs +++ b/Wonky.Client/Pages/CrmReportViewPage.razor.cs @@ -41,6 +41,7 @@ public partial class CrmReportViewPage { _report = new ReportView(); _items = new List(); + if(workDate != ReportDate) _navigator.NavigateTo($"/sales-reports/view/{workDate}"); _report = await CrmReportRepo.GetReport(workDate); diff --git a/Wonky.Client/Pages/CrmTaskItemListPage.razor b/Wonky.Client/Pages/CrmTaskItemListPage.razor index 3f75c070..0765deea 100644 --- a/Wonky.Client/Pages/CrmTaskItemListPage.razor +++ b/Wonky.Client/Pages/CrmTaskItemListPage.razor @@ -23,13 +23,13 @@
-
-

@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")

+ @*
*@ + @*

@(string.IsNullOrWhiteSpace(_workDate) ? "" : $"{DateTime.Parse(_workDate).ToLongDateString()}")

*@ + @*
*@ +
+
-
- -
- diff --git a/Wonky.Client/Pages/OfficeReportViewPage.razor b/Wonky.Client/Pages/OfficeReportViewPage.razor index cbcaaa01..a396bc75 100644 --- a/Wonky.Client/Pages/OfficeReportViewPage.razor +++ b/Wonky.Client/Pages/OfficeReportViewPage.razor @@ -22,13 +22,13 @@
-
-

@DateTime.Parse(ReportDate).ToLongDateString()

+ @*
*@ + @*

@DateTime.Parse(ReportDate).ToLongDateString()

*@ + @*
*@ +
+
-
- -
-
+
diff --git a/Wonky.Client/Program.cs b/Wonky.Client/Program.cs index c666fb96..ba76a8d1 100644 --- a/Wonky.Client/Program.cs +++ b/Wonky.Client/Program.cs @@ -78,6 +78,7 @@ builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); +builder.Services.AddScoped(); // --------------------------------------- diff --git a/Wonky.Client/Services/OrderDraftService.cs b/Wonky.Client/Services/OrderDraftService.cs new file mode 100644 index 00000000..54507785 --- /dev/null +++ b/Wonky.Client/Services/OrderDraftService.cs @@ -0,0 +1,39 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Blazored.LocalStorage; +using Wonky.Client.Models; + +namespace Wonky.Client.Services; + +public class OrderDraftService +{ + private readonly ILocalStorageService _localStorageService; + + public OrderDraftService(ILocalStorageService localStorageService) + { + _localStorageService = localStorageService; + } + + public async Task GetDraft(string companyId) + { + return await _localStorageService.GetItemAsync(companyId) ?? new Draft(); + } + + public async Task SaveDraft(string companyId, Draft draft) + { + await _localStorageService.SetItemAsync(companyId, draft); + } +} \ No newline at end of file diff --git a/Wonky.Client/Shared/ConfirmWorkDateModal.razor b/Wonky.Client/Shared/ConfirmWorkDateModal.razor new file mode 100644 index 00000000..9387291a --- /dev/null +++ b/Wonky.Client/Shared/ConfirmWorkDateModal.razor @@ -0,0 +1,38 @@ +@* +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// +*@ + + +@if (_showBackdrop) +{ + +} \ No newline at end of file diff --git a/Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs b/Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs new file mode 100644 index 00000000..55ca48fb --- /dev/null +++ b/Wonky.Client/Shared/ConfirmWorkDateModal.razor.cs @@ -0,0 +1,42 @@ +// Copyright (C) 2022 FCS Frede's Computer Services. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see [https://www.gnu.org/licenses/agpl-3.0.en.html] +// + +using Microsoft.AspNetCore.Components; + +namespace Wonky.Client.Shared; + +public partial class ConfirmWorkDateModal +{ + private string _modalDisplay = ""; + private bool _showBackdrop; + [Parameter] public string BodyMessage { get; set; } = ""; + [Parameter] public EventCallback OnOkClicked { get; set; } + + + + public void Show() + { + _modalDisplay = "block;"; + _showBackdrop = true; + StateHasChanged(); + } + + public void Hide() + { + _modalDisplay = "none;"; + _showBackdrop = false; + StateHasChanged(); + } +} \ No newline at end of file diff --git a/Wonky.Client/Shared/DraftStateProvider.razor.cs b/Wonky.Client/Shared/DraftStateProvider.razor.cs index bdb0e08e..843783e6 100644 --- a/Wonky.Client/Shared/DraftStateProvider.razor.cs +++ b/Wonky.Client/Shared/DraftStateProvider.razor.cs @@ -22,7 +22,7 @@ namespace Wonky.Client.Shared; public partial class DraftStateProvider { [Parameter] public RenderFragment ChildContent { get; set; } - [Parameter] public string Account { get; set; } = "MyCart"; + [Parameter] public string DraftId { get; set; } = ""; [Inject] public ILocalStorageService LocalStorageService { get; set; } public Draft Draft { get; set; } = new(); @@ -30,8 +30,10 @@ public partial class DraftStateProvider protected override async Task OnParametersSetAsync() { - Draft = await LocalStorageService.GetItemAsync(Account); - + if (string.IsNullOrWhiteSpace(DraftId)) + DraftId = "default"; + + Draft = await LocalStorageService.GetItemAsync(DraftId); if (Draft == null || Draft.Items.Count == 0) { Draft = new Draft(); @@ -49,12 +51,12 @@ public partial class DraftStateProvider public async Task SaveChangesAsync() { - await LocalStorageService.SetItemAsync(Account, Draft); + await LocalStorageService.SetItemAsync(DraftId, Draft); } public async Task DeleteDraftAsync() { Draft.Items.Clear(); - await LocalStorageService.SetItemAsync(Account, Draft); + await LocalStorageService.SetItemAsync(DraftId, Draft); } } \ No newline at end of file diff --git a/Wonky.Client/Shared/InformationModal.razor b/Wonky.Client/Shared/InformationModal.razor index 793dc4c3..09a08486 100644 --- a/Wonky.Client/Shared/InformationModal.razor +++ b/Wonky.Client/Shared/InformationModal.razor @@ -15,7 +15,8 @@ // *@ -