diff --git a/app/Infrastructure/Http/Controllers/DashboardController.php b/app/Infrastructure/Http/Controllers/DashboardController.php index 9f164a9..63a62d9 100644 --- a/app/Infrastructure/Http/Controllers/DashboardController.php +++ b/app/Infrastructure/Http/Controllers/DashboardController.php @@ -12,6 +12,7 @@ use Toby\Domain\UserVacationStatsRetriever; use Toby\Domain\VacationRequestStatesRetriever; use Toby\Domain\VacationTypeConfigRetriever; use Toby\Eloquent\Helpers\YearPeriodRetriever; +use Toby\Eloquent\Models\Holiday; use Toby\Eloquent\Models\VacationRequest; use Toby\Infrastructure\Http\Resources\HolidayResource; use Toby\Infrastructure\Http\Resources\VacationRequestResource; @@ -54,6 +55,8 @@ class DashboardController extends Controller ->limit(3) ->get(); + $allHolidays = $yearPeriod->holidays; + $limit = $vacationStatsRetriever->getVacationDaysLimit($user, $yearPeriod); $used = $vacationStatsRetriever->getUsedVacationDays($user, $yearPeriod); $pending = $vacationStatsRetriever->getPendingVacationDays($user, $yearPeriod); @@ -66,6 +69,9 @@ class DashboardController extends Controller "remoteDays" => VacationResource::collection($remoteDays), "vacationRequests" => VacationRequestResource::collection($vacationRequests), "holidays" => HolidayResource::collection($holidays), + "allHolidays" => $allHolidays->mapWithKeys( + fn(Holiday $holiday): array => [$holiday->date->toDateString() => $holiday->name], + ), "stats" => [ "limit" => $limit, "remaining" => $remaining, diff --git a/resources/js/Pages/Dashboard.vue b/resources/js/Pages/Dashboard.vue index 1188c6d..5b5f5ae 100644 --- a/resources/js/Pages/Dashboard.vue +++ b/resources/js/Pages/Dashboard.vue @@ -3,7 +3,9 @@
- +
@@ -50,5 +52,6 @@ defineProps({ can: Object, stats: Object, years: Object, + allHolidays: Object, }) diff --git a/resources/js/Shared/Widgets/Calendar/DateComponent.vue b/resources/js/Shared/Widgets/Calendar/DateComponent.vue new file mode 100644 index 0000000..63f6993 --- /dev/null +++ b/resources/js/Shared/Widgets/Calendar/DateComponent.vue @@ -0,0 +1,70 @@ + + + \ No newline at end of file diff --git a/resources/js/Shared/Widgets/VacationCalendar.vue b/resources/js/Shared/Widgets/VacationCalendar.vue index d8b709f..5d5dc2c 100644 --- a/resources/js/Shared/Widgets/VacationCalendar.vue +++ b/resources/js/Shared/Widgets/VacationCalendar.vue @@ -120,19 +120,14 @@ class="w-full grid grid-cols-7 gap-px" :class="{ 'grid-rows-1': calendarState.viewMode.isWeek }" > -
- -
+ :holidaydescription="getHolidayDescription" + />
@@ -147,16 +142,23 @@ import { DateTime } from 'luxon' import useCurrentYearPeriodInfo from '@/Composables/yearPeriodInfo' import { useMonthInfo } from '@/Composables/monthInfo' import { viewModes, find as findViewMode } from '@/Shared/Widgets/Calendar/ViewModeOptions' +import DateComponent from '@/Shared/Widgets/Calendar/DateComponent' + +const props = defineProps({ + holidays: Object, +}) let days = ref([]) -const months = useMonthInfo().getMonths() + function getCurrentDate() { const { year, month, weekNumber } = DateTime.now() return { year, month, week: weekNumber } } -const selectedYear = useCurrentYearPeriodInfo().year.value const currentDate = getCurrentDate() +const months = useMonthInfo().getMonths() +const selectedYear = useCurrentYearPeriodInfo().year.value + const calendar = { viewMode: ref('week'), currents: reactive({ @@ -227,6 +229,7 @@ const customCalendar = { isCurrentMonth: isInCurrentMonth(day), isToday: isToday(day), isWeekend: isWeekend(day), + isHoliday: isHoliday(day), } }, } @@ -325,6 +328,14 @@ function isWeekend(date) { function isToday(date) { return date.toISODate() === DateTime.local().toISODate() } + +function isHoliday(date) { + return props.holidays[date.toISODate()] !== undefined +} + +function getHolidayDescription(day) { + return props.holidays[day.date] +}