diff --git a/Client/Biskilog Accounting.Client.csproj b/Client/Biskilog Accounting.Client.csproj index 39d8fb6..e0344c5 100644 --- a/Client/Biskilog Accounting.Client.csproj +++ b/Client/Biskilog Accounting.Client.csproj @@ -25,6 +25,7 @@ + diff --git a/Client/Pages/Dashboard/Dashboard.razor b/Client/Pages/Dashboard/Dashboard.razor index 2f2a628..58e7963 100644 --- a/Client/Pages/Dashboard/Dashboard.razor +++ b/Client/Pages/Dashboard/Dashboard.razor @@ -12,7 +12,7 @@ - + @@ -21,64 +21,13 @@ - - - - Total Revenue - - - - - - - - 2022 - - - 2021 - 2020 - 2019 - - - - - - 62% Company Growth - - - - - - - - 2022 - $32.5k - - - - - - - - 2021 - $41.2k - - - - - - + - + diff --git a/Client/Pages/Dashboard/Dashboard.razor.cs b/Client/Pages/Dashboard/Dashboard.razor.cs index e49e32c..cde908a 100644 --- a/Client/Pages/Dashboard/Dashboard.razor.cs +++ b/Client/Pages/Dashboard/Dashboard.razor.cs @@ -7,19 +7,22 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard public partial class Dashboard { private TradeSummary m_tradeSummary { get; set; } = new TradeSummary(); + private List m_weeklySaleItems { get; set; } = new List { }; private string m_username { get; set; } = string.Empty; + private bool loadWeeklySales = true; protected override async Task OnInitializedAsync() { m_username = m_tokenService.GetUserNameFromToken(await m_tokenService.GetToken())!; - await GetSummary(); + await GetTradeSummary(); + await GetWeeklySales(); return; } - + /// /// Gets the tade summary /// /// - async Task GetSummary() + async Task GetTradeSummary() { try { @@ -32,7 +35,32 @@ namespace Biskilog_Accounting.Client.Pages.Dashboard m_tradeSummary = tradeSummary; StateHasChanged(); } - }catch (Exception ex) + } + catch (Exception ex) + { + Console.WriteLine(ex.Message); + } + } + /// + /// Gets the tade summary + /// + /// + async Task GetWeeklySales() + { + try + { + var response = await m_http.GetAsync("api/analytics/sales/weekly"); + if (response.IsSuccessStatusCode) + { + var jsonContent = await response.Content.ReadAsStringAsync(); + var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; + var sales = JsonSerializer.Deserialize>(jsonContent, options); + m_weeklySaleItems = sales; + loadWeeklySales = false; + StateHasChanged(); + } + } + catch (Exception ex) { Console.WriteLine(ex.Message); } diff --git a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor index ca14085..fd23ef1 100644 --- a/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor +++ b/Client/Pages/Dashboard/Elements/AnalyticsItemSmall.razor @@ -1,4 +1,7 @@ - +@using Biskilog_Accounting.Shared.Interfaces +@inject ICalculator m_calculator + + @@ -22,7 +25,7 @@ @Title - @Value - @Percentage % + @(m_calculator.FormatMoneyWithCurrency(Value)) + @(Percentage.ToString("0.00")) % \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/ChartElement.razor b/Client/Pages/Dashboard/Elements/ChartElement.razor new file mode 100644 index 0000000..4f032ec --- /dev/null +++ b/Client/Pages/Dashboard/Elements/ChartElement.razor @@ -0,0 +1,58 @@ +@using Biskilog_Accounting.Shared.CustomModels; +@using Biskilog_Accounting.Shared.Interfaces; +@inject ICalculator m_calculator + +@if (!IsLoading) +{ + + + + @Title + + + + + + + @SubTitle + + + + + + + + + + Best Day + @m_bestDay + @m_bestSales + + + + + + + + Worst Day + @m_worstDay + @m_worstSales + + + + + + +}else{ + +} \ No newline at end of file diff --git a/Client/Pages/Dashboard/Elements/ChartElement.razor.cs b/Client/Pages/Dashboard/Elements/ChartElement.razor.cs new file mode 100644 index 0000000..bf52f3d --- /dev/null +++ b/Client/Pages/Dashboard/Elements/ChartElement.razor.cs @@ -0,0 +1,46 @@ +using ApexCharts; +using Biskilog_Accounting.Shared.CustomModels; +using Microsoft.AspNetCore.Components; + +namespace Biskilog_Accounting.Client.Pages.Dashboard.Elements +{ + public partial class ChartElement + { + [Parameter] + public bool IsLoading { get; set; } + [Parameter] + public string Title { get; set; } = string.Empty; + [Parameter] + public string SubTitle { get; set; } = string.Empty; + [Parameter] + public List Series { get; set; } = new List(); + private ApexChartOptions m_options; + + private string m_bestDay { get; set; } = string.Empty; + private string m_worstDay { get; set; } = string.Empty; + private string m_bestSales { get; set; } = string.Empty; + private string m_worstSales { get; set; } = string.Empty; + protected override void OnParametersSet() + { + m_options = new ApexChartOptions + { + PlotOptions = new PlotOptions + { + Bar = new PlotOptionsBar + { + ColumnWidth = "7", + + } + } + }; + if (Series.Count > 1) + { + m_bestDay = Series.OrderByDescending(t => t.Total).First().Date.ToShortDateString(); + m_bestSales = m_calculator.FormatMoneyWithCurrency((double)Series.OrderByDescending(t => t.Total).First().Total); + m_worstDay = Series.OrderByDescending(t => t.Total).Last().Date.ToShortDateString(); + m_worstSales = m_calculator.FormatMoneyWithCurrency((double)Series.OrderByDescending(t => t.Total).Last().Total); + } + base.OnParametersSet(); + } + } +} diff --git a/Client/_Imports.razor b/Client/_Imports.razor index b7485da..bb5b0c1 100644 --- a/Client/_Imports.razor +++ b/Client/_Imports.razor @@ -5,3 +5,4 @@ @using Microsoft.AspNetCore.Components.WebAssembly.Http @using Microsoft.JSInterop @using Biskilog_Accounting.Client +@using ApexCharts; \ No newline at end of file diff --git a/Client/wwwroot/index.html b/Client/wwwroot/index.html index 42dfb0b..5cc4985 100644 --- a/Client/wwwroot/index.html +++ b/Client/wwwroot/index.html @@ -47,6 +47,8 @@ 🗙 + +