Skip to content

Commit

Permalink
#1414 fix structure tab data
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganes556 committed Feb 4, 2025
1 parent c947703 commit 6c1e1b1
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions app/Actions/UI/Dashboards/ShowGroupDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,22 @@ public function getDashboardInterval(Group $group, array $userSettings): array
'current' => $this->tabDashboardInterval,
'navigation' => DashboardIntervalTabsEnum::navigation()
], */
'table' => DashboardIntervalTabsEnum::navigation()[$this->tabDashboardInterval],
'table' => [
[
'tab_label' => __('sales'),
'tab_slug' => 'sales',
'tab_icon' => 'fas fa-chart-line',
'type' => 'table',
'data' => null
],
[
'tab_label' => __('shops'),
'tab_slug' => 'shops',
'tab_icon' => 'fal fa-shopping-cart',
'type' => 'table',
'data' => null
]
],
'widgets' => [
'column_count' => 4,
'components' => []
Expand All @@ -87,7 +102,7 @@ public function getDashboardInterval(Group $group, array $userSettings): array
if ($this->tabDashboardInterval == DashboardIntervalTabsEnum::SALES->value) {
$total['total_sales'] = $organisations->sum(fn ($organisation) => $organisation->salesIntervals->{"sales_grp_currency_$selectedInterval"} ?? 0);

$dashboard['table']['data'] = $organisations->map(function (Organisation $organisation) use ($selectedInterval, $group, &$dashboard, $selectedCurrency, &$visualData, &$total) {
$dashboard['table'][0]['data'] = $organisations->map(function (Organisation $organisation) use ($selectedInterval, $group, &$dashboard, $selectedCurrency, &$visualData, &$total) {
$keyCurrency = $dashboard['settings']['key_currency'];
$currencyCode = $selectedCurrency === $keyCurrency ? $group->currency->code : $organisation->currency->code;
$salesCurrency = 'sales_'.$selectedCurrency.'_currency';
Expand Down Expand Up @@ -146,7 +161,7 @@ public function getDashboardInterval(Group $group, array $userSettings): array
$shops = $group->shops->whereIn('organisation_id', $organisations->pluck('id')->toArray());
$total['total_sales'] = $shops->sum(fn ($shop) => $shop->salesIntervals->{"sales_grp_currency_$selectedInterval"} ?? 0);

$dashboard['table']['data'] = $shops->map(function (Shop $shop) use ($selectedInterval, $group, &$dashboard, $selectedCurrency, &$visualData, &$total) {
$dashboard['table'][1]['data'] = $shops->map(function (Shop $shop) use ($selectedInterval, $group, &$dashboard, $selectedCurrency, &$visualData, &$total) {
$keyCurrency = $dashboard['settings']['key_currency'];
$currencyCode = $selectedCurrency === $keyCurrency ? $group->currency->code : $shop->organisation->currency->code;
$salesCurrency = 'sales_'.$selectedCurrency.'_currency';
Expand Down

0 comments on commit 6c1e1b1

Please sign in to comment.