Update holidays-ical.blade.php
Some checks failed
tests / ci (push) Has been cancelled

*Past events are removed.
*Events that started earlier but are still ongoing today remain visible.
*Anything from today onward displays.
This commit is contained in:
dowjames 2025-12-27 16:24:18 -05:00 committed by Benjamin Nussbaum
parent f1a9103f0d
commit 0b2b5bf25f

View file

@ -2,36 +2,46 @@
@php
use Carbon\Carbon;
$today = Carbon::today(config('app.timezone'));
$events = collect($data['ical'] ?? [])
->map(function (array $event): array {
$start = null;
$end = null;
try {
$start = isset($event['DTSTART']) ? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone')) : null;
$start = isset($event['DTSTART'])
? Carbon::parse($event['DTSTART'])->setTimezone(config('app.timezone'))
: null;
} catch (Exception $e) {
$start = null;
}
try {
$end = isset($event['DTEND']) ? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone')) : null;
$end = isset($event['DTEND'])
? Carbon::parse($event['DTEND'])->setTimezone(config('app.timezone'))
: null;
} catch (Exception $e) {
$end = null;
}
return [
'summary' => $event['SUMMARY'] ?? 'Untitled event',
'location' => $event['LOCATION'] ?? null,
'location' => $event['LOCATION'] ?? '—',
'start' => $start,
'end' => $end,
];
})
->filter(fn ($event) => $event['start'])
->filter(fn ($event) =>
$event['start'] &&
(
$event['start']->greaterThanOrEqualTo($today) ||
($event['end'] && $event['end']->greaterThanOrEqualTo($today))
)
)
->sortBy('start')
->take($size === 'quadrant' ? 5 : 8)
->values();
@endphp
<x-trmnl::view size="{{$size}}">
<x-trmnl::layout class="layout--col gap--small">
<x-trmnl::table>