Replace the demo home page with a dashboard
Everyone sees their open tasks on an agenda, their open jobs, this week's hours and quick links. Admin and management also get a lazily loaded management panel: things to do, the month so far against the previous month, jobs and late work, and everyone's workload. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Modules\Dashboard\Domain\Enums;
|
||||
|
||||
/**
|
||||
* Where an open task falls on the home page's agenda: late (due before
|
||||
* today), today or tomorrow (due, starting or under way by tomorrow), later
|
||||
* this week, or later still.
|
||||
*/
|
||||
enum AgendaBucket: string
|
||||
{
|
||||
case Overdue = 'overdue';
|
||||
case Soon = 'soon';
|
||||
case ThisWeek = 'this_week';
|
||||
case Later = 'later';
|
||||
|
||||
/**
|
||||
* Days are Y-m-d. A task with no dates is "later".
|
||||
*/
|
||||
public static function of(?string $dueOn, ?string $plannedFrom, string $today, string $tomorrow, string $weekEnd): self
|
||||
{
|
||||
if ($dueOn !== null && $dueOn < $today) {
|
||||
return self::Overdue;
|
||||
}
|
||||
|
||||
$nearest = min(array_filter([$dueOn, $plannedFrom]) ?: ['9999-12-31']);
|
||||
|
||||
return match (true) {
|
||||
$nearest <= $tomorrow => self::Soon,
|
||||
$nearest <= $weekEnd => self::ThisWeek,
|
||||
default => self::Later,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user