Skip to content

Commit

Permalink
#1414 add dashboard enum
Browse files Browse the repository at this point in the history
  • Loading branch information
Ganes556 committed Feb 4, 2025
1 parent 5152bd3 commit f4ff03b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
29 changes: 28 additions & 1 deletion app/Actions/Traits/WithDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,34 @@
namespace App\Actions\Traits;

use App\Enums\DateIntervals\DateIntervalEnum;
use App\Enums\EnumHelperTrait;
use App\Enums\HasTabs;
use Illuminate\Support\Arr;

enum DashboardIntervalTabsEnum: string
{
use EnumHelperTrait;
use HasTabs;

case SALES = 'sales';
case ORDERS = 'orders';

public function blueprint(): array
{
return match ($this) {
DashboardIntervalTabsEnum::SALES => [
'title' => __('sales'),
'icon' => 'fas fa-chart-line',
],
DashboardIntervalTabsEnum::ORDERS => [
'title' => __('orders'),
'icon' => 'fal fa-shopping-cart'
],
};
}
}


trait WithDashboard
{
protected ?string $tabDashboardInterval = null;
Expand Down Expand Up @@ -64,8 +90,9 @@ public function getWidget($type = 'basic', $colSpan = 1, $rowSpan = 1, array $ro
];
}

public function withTabDashboardInterval(array $tabs): static
public function withTabDashboardInterval(): static
{
$tabs = DashboardIntervalTabsEnum::values();
$tab = $this->get('tab_dashboard_interval', Arr::first($tabs));

if (!in_array($tab, $tabs)) {
Expand Down
5 changes: 3 additions & 2 deletions app/Actions/UI/Dashboards/ShowGroupDashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace App\Actions\UI\Dashboards;

use App\Actions\OrgAction;
use App\Actions\Traits\DashboardIntervalTabsEnum;
use App\Actions\Traits\WithDashboard;
use App\Enums\SysAdmin\Organisation\OrganisationTypeEnum;
use App\Models\SysAdmin\Group;
Expand Down Expand Up @@ -62,7 +63,7 @@ public function getDashboardInterval(Group $group, array $userSettings): array
],
'tabs' => [
'current' => $this->tabDashboardInterval,
'navigation' => ['sales', 'profile']
'navigation' => DashboardIntervalTabsEnum::navigation()
],
'table' => [

Expand Down Expand Up @@ -258,7 +259,7 @@ public function getDashboardInterval(Group $group, array $userSettings): array
public function asController(ActionRequest $request): Response
{
$group = group();
$this->initialisationFromGroup($group, $request)->withTabDashboardInterval(['sales', 'profile']);
$this->initialisationFromGroup($group, $request)->withTabDashboardInterval();
return $this->handle($group);
}

Expand Down

0 comments on commit f4ff03b

Please sign in to comment.