Skip to content

Commit 0fd46c4

Browse files
author
Itamar Junior
committed
feat: add monthly view mode to budget calendar with item listing
1 parent acbdb9d commit 0fd46c4

File tree

1 file changed

+68
-0
lines changed

1 file changed

+68
-0
lines changed

resources/views/livewire/company/budget-calendar.blade.php

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,74 @@ class="absolute top-2 right-2 text-gray-400 hover:text-gray-600">
192192
</div>
193193
@endif
194194

195+
@if ($viewMode === 'monthly')
196+
@php
197+
$currentMonthStart = $currentDate->copy()->startOfMonth()->toDateString();
198+
$currentMonthEnd = $currentDate->copy()->endOfMonth()->toDateString();
199+
200+
$monthlyDueItems = collect($dueDatesByDay)
201+
->filter(fn($items, $date) => $date >= $currentMonthStart && $date <= $currentMonthEnd)
202+
->flatMap(fn($items) => $items)
203+
->sortBy('next_due_date');
204+
@endphp
205+
<section class="mt-12 md:mt-0 md:pl-14 w-full">
206+
<h2 class="text-base font-semibold text-gray-900">Monthly Budget for
207+
{{ $currentDate->format('F Y') }}</h2>
208+
<ol class="mt-4 flex flex-col gap-y-1 text-sm/6 text-gray-500">
209+
@forelse ($monthlyDueItems as $dueItem)
210+
<li
211+
class="group flex items-center rounded-xl px-4 py-2 focus-within:bg-gray-100 hover:bg-gray-100">
212+
<div class="flex-auto">
213+
<p class="text-gray-900">{{ $dueItem->category->name ?? '-' }}</p>
214+
<p class="mt-0.5">{{ $dueItem->provider->name ?? '-' }}</p>
215+
<p class="mt-0.5">
216+
{{ \Carbon\Carbon::parse($dueItem->next_due_date)->format('j M, Y') }}</p>
217+
<p class="mt-0.5 font-semibold text-indigo-700">
218+
{{ Number::currency($dueItem->budget, 'EUR') }}</p>
219+
</div>
220+
<div class="relative opacity-0 focus-within:opacity-100 group-hover:opacity-100"
221+
x-data="{ open: false }" @click.away="open = false">
222+
<div>
223+
<button type="button" x-on:click="open = !open"
224+
class="-m-2 flex items-center rounded-full p-1.5 text-gray-500 hover:text-gray-600"
225+
id="menu-0-button" aria-expanded="false" aria-haspopup="true">
226+
<span class="sr-only">Open options</span>
227+
<svg xmlns="http://www.w3.org/2000/svg" fill="none"
228+
viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor"
229+
class="size-6 text-gray-400">
230+
<path stroke-linecap="round" stroke-linejoin="round"
231+
d="M8.625 12a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H8.25m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0H12m4.125 0a.375.375 0 1 1-.75 0 .375.375 0 0 1 .75 0Zm0 0h-.375M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" />
232+
</svg>
233+
</button>
234+
</div>
235+
236+
<div x-show="open" x-transition:enter="transition ease-out duration-100"
237+
x-transition:enter-start="transform opacity-0 scale-95"
238+
x-transition:enter-end="transform opacity-100 scale-100"
239+
x-transition:leave="transition ease-in duration-75"
240+
x-transition:leave-start="transform opacity-100 scale-100"
241+
x-transition:leave-end="transform opacity-0 scale-95"
242+
class="absolute right-0 z-10 mt-2 w-36 origin-top-right rounded-md bg-white shadow-lg ring-1 ring-black/5 focus:outline-none"
243+
role="menu" aria-orientation="vertical"
244+
aria-labelledby="menu-0-button" tabindex="-1">
245+
<div class="py-1" role="none">
246+
<a href="#"
247+
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"
248+
role="menuitem" tabindex="-1" id="menu-0-item-0">Edit</a>
249+
<a href="#"
250+
class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100"
251+
role="menuitem" tabindex="-1" id="menu-0-item-1">Cancel</a>
252+
</div>
253+
</div>
254+
</div>
255+
</li>
256+
@empty
257+
<li class="text-gray-500 italic">No budget items this month.</li>
258+
@endforelse
259+
</ol>
260+
</section>
261+
@endif
262+
195263

196264
</div>
197265
</div>

0 commit comments

Comments
 (0)