#39 - generate timesheet #56

Merged
Baakoma merged 9 commits from #39-generate-timesheet into main 2022-02-21 16:09:45 +01:00
6 changed files with 81 additions and 61 deletions
Showing only changes of commit 9ada0f843d - Show all commits

View File

@@ -4,9 +4,8 @@ declare(strict_types=1);
namespace Toby\Domain;
use Carbon\CarbonImmutable;
use Carbon\CarbonInterface;
use Carbon\CarbonPeriod;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Toby\Domain\Enums\VacationRequestState;
use Toby\Eloquent\Helpers\YearPeriodRetriever;
@@ -20,33 +19,16 @@ class CalendarGenerator
) {
}
public function generate(YearPeriod $yearPeriod, string $month): array
public function generate(Carbon $month): array
{
$date = CarbonImmutable::create($yearPeriod->year, $this->monthNameToNumber($month));
$period = CarbonPeriod::create($date->startOfMonth(), $date->endOfMonth());
$period = CarbonPeriod::create($month->copy()->startOfMonth(), $month->copy()->endOfMonth());
$yearPeriod = YearPeriod::findByYear($month->year);
$holidays = $yearPeriod->holidays()->pluck("date");
return $this->generateCalendar($period, $holidays);
}
protected function monthNameToNumber(string $name): int
{
return match ($name) {
default => CarbonInterface::JANUARY,
"february" => CarbonInterface::FEBRUARY,
"march" => CarbonInterface::MARCH,
"april" => CarbonInterface::APRIL,
"may" => CarbonInterface::MAY,
"june" => CarbonInterface::JUNE,
"july" => CarbonInterface::JULY,
"august" => CarbonInterface::AUGUST,
"september" => CarbonInterface::SEPTEMBER,
"october" => CarbonInterface::OCTOBER,
"november" => CarbonInterface::NOVEMBER,
"december" => CarbonInterface::DECEMBER,
};
}
protected function generateCalendar(CarbonPeriod $period, Collection $holidays): array
{
$calendar = [];

View File

@@ -0,0 +1,59 @@
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
<?php
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
declare(strict_types=1);
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
namespace Toby\Domain\Enums;
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
use Carbon\CarbonInterface;
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
use Illuminate\Support\Carbon;
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
use Illuminate\Support\Str;
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
enum Month: string
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
{
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case January = "january";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case February = "february";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case March = "march";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case April = "april";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case May = "may";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case June = "june";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case July = "july";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case August = "august";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case September = "september";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case October = "october";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case November = "november";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
case December = "december";
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
public function toCarbonNumber(): int
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
{
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
return match ($this) {
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::January => CarbonInterface::JANUARY,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::February => CarbonInterface::FEBRUARY,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::March => CarbonInterface::MARCH,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::April => CarbonInterface::APRIL,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::May => CarbonInterface::MAY,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::June => CarbonInterface::JUNE,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::July => CarbonInterface::JULY,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::August => CarbonInterface::AUGUST,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::September => CarbonInterface::SEPTEMBER,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::October => CarbonInterface::OCTOBER,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::November => CarbonInterface::NOVEMBER,
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
self::December => CarbonInterface::DECEMBER,
krzysztofrewak commented 2022-02-21 15:32:49 +01:00 (Migrated from github.com)
Review
            static::January => CarbonInterface::JANUARY,
            static::February => CarbonInterface::FEBRUARY,
            static::March => CarbonInterface::MARCH,
            static::April => CarbonInterface::APRIL,
            static::May => CarbonInterface::MAY,
            static::June => CarbonInterface::JUNE,
            static::July => CarbonInterface::JULY,
            static::August => CarbonInterface::AUGUST,
            static::September => CarbonInterface::SEPTEMBER,
            static::October => CarbonInterface::OCTOBER,
            static::November => CarbonInterface::NOVEMBER,
            static::December => CarbonInterface::DECEMBER,
```suggestion static::January => CarbonInterface::JANUARY, static::February => CarbonInterface::FEBRUARY, static::March => CarbonInterface::MARCH, static::April => CarbonInterface::APRIL, static::May => CarbonInterface::MAY, static::June => CarbonInterface::JUNE, static::July => CarbonInterface::JULY, static::August => CarbonInterface::AUGUST, static::September => CarbonInterface::SEPTEMBER, static::October => CarbonInterface::OCTOBER, static::November => CarbonInterface::NOVEMBER, static::December => CarbonInterface::DECEMBER, ```
krzysztofrewak commented 2022-02-21 15:33:17 +01:00 (Migrated from github.com)
Review

Plus maybe some exception could be thrown on unknow value/default?

Plus maybe some exception could be thrown on unknow value/default?
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
Baakoma commented 2022-02-21 15:48:14 +01:00 (Migrated from github.com)
Review

image

![image](https://user-images.githubusercontent.com/16743001/154977581-bb213207-098b-4e9d-8feb-7d1b5c69e4e5.png)
};
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
}
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
public static function current(): Month
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
{
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
return Month::from(Str::lower(Carbon::now()->englishMonth));
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
}
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
public static function fromNameOrCurrent(string $name): Month
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
{
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
$month = Month::tryFrom($name);
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
if ($month === null) {
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
return Month::current();
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
}
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
return $month;
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
}
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```
}
mtracz commented 2022-02-21 15:39:05 +01:00 (Migrated from github.com)
Review

I think we can simplify it:

        return Month::tryFrom($name) ?? Month::current();     
I think we can simplify it: ```suggestion return Month::tryFrom($name) ?? Month::current(); ```

View File

@@ -4,54 +4,32 @@ declare(strict_types=1);
namespace Toby\Infrastructure\Http\Controllers;
use Carbon\CarbonInterface;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Maatwebsite\Excel\Facades\Excel;
use Symfony\Component\HttpFoundation\BinaryFileResponse;
use Toby\Domain\Enums\Month;
use Toby\Domain\TimesheetExport;
use Toby\Eloquent\Helpers\YearPeriodRetriever;
use Toby\Eloquent\Models\User;
class TimesheetController extends Controller
{
public function __invoke(Request $request, YearPeriodRetriever $yearPeriodRetriever): BinaryFileResponse
public function __invoke(Month $month, YearPeriodRetriever $yearPeriodRetriever): BinaryFileResponse
{
$yearPeriod = $yearPeriodRetriever->selected();
$month = Str::lower($request->query("month", Carbon::now()->englishMonth));
$month = Carbon::create($yearPeriod->year, $this->monthNameToNumber($month));
$carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber());
$users = User::query()
->orderBy("last_name")
->orderBy("first_name")
->get();
$filename = "{$month->translatedFormat("F Y")}.xlsx";
$filename = "{$carbonMonth->translatedFormat("F Y")}.xlsx";
$timesheet = (new TimesheetExport())
->forMonth($month)
->forMonth($carbonMonth)
->forUsers($users);
return Excel::download($timesheet, $filename);
}
protected function monthNameToNumber(string $name): int
{
return match ($name) {
default => CarbonInterface::JANUARY,
"february" => CarbonInterface::FEBRUARY,
"march" => CarbonInterface::MARCH,
"april" => CarbonInterface::APRIL,
"may" => CarbonInterface::MAY,
"june" => CarbonInterface::JUNE,
"july" => CarbonInterface::JULY,
"august" => CarbonInterface::AUGUST,
"september" => CarbonInterface::SEPTEMBER,
"october" => CarbonInterface::OCTOBER,
"november" => CarbonInterface::NOVEMBER,
"december" => CarbonInterface::DECEMBER,
};
}
}

View File

@@ -4,11 +4,10 @@ declare(strict_types=1);
namespace Toby\Infrastructure\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Inertia\Response;
use Toby\Domain\CalendarGenerator;
use Toby\Domain\Enums\Month;
use Toby\Eloquent\Helpers\YearPeriodRetriever;
use Toby\Eloquent\Models\User;
use Toby\Infrastructure\Http\Resources\UserResource;
@@ -16,22 +15,25 @@ use Toby\Infrastructure\Http\Resources\UserResource;
class VacationCalendarController extends Controller
{
public function index(
Request $request,
YearPeriodRetriever $yearPeriodRetriever,
CalendarGenerator $calendarGenerator,
?string $month = null,
): Response {
$month = Str::lower($request->query("month", Carbon::now()->englishMonth));
$month = Month::fromNameOrCurrent((string)$month);
$yearPeriod = $yearPeriodRetriever->selected();
$carbonMonth = Carbon::create($yearPeriod->year, $month->toCarbonNumber());
$users = User::query()
->orderBy("last_name")
->orderBy("first_name")
->get();
$calendar = $calendarGenerator->generate($yearPeriod, $month);
$calendar = $calendarGenerator->generate($carbonMonth);
return inertia("Calendar", [
"calendar" => $calendar,
"currentMonth" => $month,
"currentMonth" => $month->value,
"users" => UserResource::collection($users),
]);
}

View File

@@ -9,7 +9,7 @@
</div>
<div>
<a
:href="`timesheet?month=${currentMonth}`"
:href="`timesheet/${selectedMonth.value}`"
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
>
Pobierz plik excel
@@ -52,8 +52,7 @@
v-slot="{ active }"
>
<InertiaLink
href="/vacation-calendar"
:data="{ month: month.value }"
:href="`/vacation-calendar/${month.value}`"
:class="[active ? 'bg-gray-100 text-gray-900' : 'text-gray-700', 'flex w-full font-normal px-4 py-2 text-sm']"
>
{{ month.name }}

View File

@@ -25,9 +25,9 @@ Route::middleware("auth")->group(function (): void {
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])
->name("vacation.limits");
Route::get("/vacation-calendar", [VacationCalendarController::class, "index"])
Route::get("/vacation-calendar/{month?}", [VacationCalendarController::class, "index"])
->name("vacation.calendar");
Route::get("/timesheet", TimesheetController::class)
Route::get("/timesheet/{month}", TimesheetController::class)
->name("timesheet");
Route::get("/vacation-limits", [VacationLimitController::class, "edit"])->name("vacation.limits");