libra/docs/stories/story-7.6-booking-limit-ind...

105 lines
2.8 KiB
Markdown

# Story 7.6: Booking Limit Indicator
## Epic Reference
**Epic 7:** Client Dashboard
## User Story
As a **client**,
I want **to see my booking status and limits clearly**,
So that **I understand when I can book consultations**.
## Acceptance Criteria
### Display Locations
- [ ] Dashboard widget
- [ ] Booking page
### Status Messages
- [ ] "You can book a consultation today"
- [ ] "You already have a booking for today"
- [ ] "You have a pending request for [date]"
### Calendar Integration
- [ ] Calendar shows booked days as unavailable
- [ ] Visual indicator for user's booked dates
### Information
- [ ] Clear messaging about 1-per-day limit
- [ ] Bilingual messages
## Technical Notes
```php
new class extends Component {
public function getBookingStatus(): array
{
$user = auth()->user();
$todayBooking = $user->consultations()
->whereDate('scheduled_date', today())
->whereIn('status', ['pending', 'approved'])
->first();
$pendingRequests = $user->consultations()
->pending()
->get();
$upcomingApproved = $user->consultations()
->approved()
->where('scheduled_date', '>=', today())
->get();
return [
'canBookToday' => is_null($todayBooking),
'todayBooking' => $todayBooking,
'pendingRequests' => $pendingRequests,
'upcomingApproved' => $upcomingApproved,
'bookedDates' => $user->consultations()
->whereIn('status', ['pending', 'approved'])
->where('scheduled_date', '>=', today())
->pluck('scheduled_date')
->map(fn($d) => $d->format('Y-m-d'))
->toArray(),
];
}
};
```
### Template
```blade
<div class="bg-cream rounded-lg p-4">
@if($canBookToday)
<div class="flex items-center gap-2 text-success">
<flux:icon name="check-circle" class="w-5 h-5" />
<span>{{ __('booking.can_book_today') }}</span>
</div>
@else
<div class="flex items-center gap-2 text-warning">
<flux:icon name="exclamation-circle" class="w-5 h-5" />
<span>{{ __('booking.already_booked_today') }}</span>
</div>
@endif
@if($pendingRequests->isNotEmpty())
<p class="mt-2 text-sm text-charcoal/70">
{{ __('booking.pending_for_date', ['date' => $pendingRequests->first()->scheduled_date->format('d/m/Y')]) }}
</p>
@endif
<p class="mt-2 text-sm text-charcoal/70">
{{ __('booking.limit_message') }}
</p>
</div>
```
## Definition of Done
- [ ] Status displays on dashboard
- [ ] Status displays on booking page
- [ ] Calendar highlights booked dates
- [ ] Messages are accurate
- [ ] Bilingual support
- [ ] Tests pass
## Estimation
**Complexity:** Low | **Effort:** 2 hours