#39 - generate timesheet #56

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

View File

@@ -48,6 +48,6 @@ 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(); ```
public static function fromNameOrCurrent(string $name): Month
{
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::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(); ```
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

@@ -7,6 +7,7 @@ namespace Toby\Domain;
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Carbon;
use Maatwebsite\Excel\Concerns\WithMultipleSheets;
use Toby\Eloquent\Models\User;
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
class TimesheetExport implements WithMultipleSheets
{
@@ -15,13 +16,9 @@ class TimesheetExport implements WithMultipleSheets
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
public function sheets(): array
{
$sheets = [];
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
foreach ($this->users as $user) {
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
$sheets[] = new TimesheetPerUserSheet($user, $this->month);
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
}
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
return $sheets;
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
return $this->users
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
->map(fn(User $user) => new TimesheetPerUserSheet($user, $this->month))
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
->toArray();
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
}
public function forUsers(Collection $users): static
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?
krzysztofrewak commented 2022-02-21 15:33:37 +01:00 (Migrated from github.com)
Review

Why not to use map()?

Why not to use `map()`?

View File

@@ -35,6 +35,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
use RegistersEventListeners;
protected const HOURS_PER_DAY = 8;
protected const START_HOUR = 8;
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
protected const END_HOUR = 16;
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
public function __construct(
protected User $user,
@@ -79,8 +81,8 @@ class TimesheetPerUserSheet implements WithTitle, WithHeadings, WithEvents, With
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
$row = [
Date::dateTimeToExcel($day),
$day->translatedFormat("l"),
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(8)) : null,
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(16)) : null,
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::START_HOUR)) : null,
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
$workedThisDay ? $this->toExcelTime(Carbon::createFromTime(static::END_HOUR)) : null,
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
$workedThisDay ? static::HOURS_PER_DAY : null,
];
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?
mtracz commented 2022-02-21 15:40:19 +01:00 (Migrated from github.com)
Review

Maybe move these hours to consts as start hour and end hour?

Maybe move these hours to consts as start hour and end hour?

View File

@@ -2,6 +2,7 @@
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
declare(strict_types=1);
use Maatwebsite\Excel\DefaultValueBinder;
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
use Maatwebsite\Excel\Excel;
return [
@@ -75,7 +76,7 @@ return [
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
"pdf" => Excel::DOMPDF,
],
"value_binder" => [
"default" => Maatwebsite\Excel\DefaultValueBinder::class,
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
"default" => DefaultValueBinder::class,
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
],
"cache" => [
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.
krzysztofrewak commented 2022-02-21 15:34:57 +01:00 (Migrated from github.com)
Review

I would import that too.

I would import that too.

View File

@@ -9,7 +9,7 @@
</div>
<div>
<a
:href="`timesheet/${selectedMonth.value}`"
: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