libra/docs/stories/story-7.2-my-consultations-...

183 lines
5.7 KiB
Markdown

# Story 7.2: My Consultations View
## Epic Reference
**Epic 7:** Client Dashboard
## User Story
As a **client**,
I want **to view all my consultations**,
So that **I can track upcoming appointments and review past sessions**.
## Dependencies
- **Story 7.1:** Client Dashboard Overview (navigation context)
- **Epic 3:** Consultation model with scopes (`approved()`, `pending()`)
- **Story 3.6:** Calendar file generation (.ics) for download functionality
## Acceptance Criteria
### Upcoming Consultations Section
- [ ] Date and time (formatted per locale)
- [ ] Consultation type (free/paid)
- [ ] Status (approved/pending)
- [ ] Payment status (for paid consultations)
- [ ] Download .ics calendar file button
### Pending Requests Section
- [ ] Submitted bookings awaiting approval
- [ ] Submission date
- [ ] Problem summary preview (truncated)
- [ ] Status: "Pending Review"
### Past Consultations Section
- [ ] Historical consultations
- [ ] Status (completed/cancelled/no-show)
- [ ] Date and type
### Features
- [ ] Visual status indicators (badges with colors)
- [ ] Sort by date (default: newest first for past)
- [ ] Pagination if many consultations (10 per page)
- [ ] No edit/cancel capabilities (read-only)
### Empty States
- [ ] "No upcoming consultations" message with link to book
- [ ] "No pending requests" message
- [ ] "No past consultations" message
## Technical Notes
### Files to Create/Modify
- `resources/views/livewire/client/consultations.blade.php` - Main Volt component
- `routes/web.php` - Add route within client middleware group
### Route Definition
```php
// In routes/web.php, within authenticated client routes
Route::get('/client/consultations', function () {
return view('livewire.client.consultations');
})->name('client.consultations');
```
### Volt Component Structure
```php
<?php
use App\Models\Consultation;
use Livewire\Volt\Component;
use Livewire\WithPagination;
new class extends Component {
use WithPagination;
public function with(): array
{
$user = auth()->user();
return [
'upcoming' => $user->consultations()
->approved()
->where('scheduled_date', '>=', today())
->orderBy('scheduled_date')
->orderBy('scheduled_time')
->get(),
'pending' => $user->consultations()
->pending()
->latest()
->get(),
'past' => $user->consultations()
->whereIn('status', ['completed', 'cancelled', 'no_show'])
->orWhere(fn($q) => $q
->where('user_id', $user->id)
->approved()
->where('scheduled_date', '<', today()))
->latest('scheduled_date')
->paginate(10),
];
}
public function downloadCalendar(Consultation $consultation): \Symfony\Component\HttpFoundation\StreamedResponse
{
// Reuse .ics generation from Story 3.6
return $consultation->generateIcsDownload();
}
}; ?>
```
### Model Scopes Required (from Epic 3)
The Consultation model should have these scopes:
- `scopeApproved($query)` - `where('status', 'approved')`
- `scopePending($query)` - `where('status', 'pending')`
### Flux UI Components to Use
- `<flux:badge>` - Status indicators (approved=green, pending=yellow, completed=gray, cancelled=red)
- `<flux:button>` - Download calendar button
- `<flux:heading>` - Section headings
- `<flux:text>` - Consultation details
### Status Badge Colors
| Status | Color | Variant |
|--------|-------|---------|
| approved | green | `variant="success"` |
| pending | yellow | `variant="warning"` |
| completed | gray | `variant="subtle"` |
| cancelled | red | `variant="danger"` |
| no_show | red | `variant="danger"` |
### Payment Status Display
- For paid consultations, show payment status:
- "Payment Pending" (yellow badge)
- "Payment Received" (green badge)
- For free consultations, show "Free" (blue badge)
## References
- `docs/epics/epic-3-booking-consultation.md` - Consultation model, statuses, payment handling
- `docs/epics/epic-3-booking-consultation.md#story-36` - .ics calendar file generation
- `docs/stories/story-7.1-client-dashboard-overview.md` - Dashboard navigation context
## Test Scenarios
### Access Control
- [ ] Unauthenticated users redirected to login
- [ ] User sees only their own consultations (not other users')
### Upcoming Section
- [ ] Shows approved consultations with `scheduled_date >= today`
- [ ] Sorted by date ascending (soonest first)
- [ ] Displays type, status, payment status correctly
- [ ] Calendar download button triggers .ics download
### Pending Section
- [ ] Shows consultations with status='pending'
- [ ] Displays submission date and problem summary
- [ ] Summary truncated if too long
### Past Section
- [ ] Shows completed, cancelled, no_show consultations
- [ ] Shows approved consultations with `scheduled_date < today`
- [ ] Sorted by date descending (newest first)
- [ ] Pagination works correctly (10 per page)
### Empty States
- [ ] Empty upcoming shows appropriate message
- [ ] Empty pending shows appropriate message
- [ ] Empty past shows appropriate message
### Calendar Download
- [ ] Download generates valid .ics file
- [ ] File contains correct consultation details
- [ ] Only available for approved upcoming consultations
## Definition of Done
- [ ] All sections display correctly
- [ ] Calendar download works
- [ ] Status indicators clear and color-coded
- [ ] Read-only (no actions except download)
- [ ] Pagination works for past consultations
- [ ] Empty states display appropriately
- [ ] Mobile responsive
- [ ] Bilingual support
- [ ] Tests pass
## Estimation
**Complexity:** Medium | **Effort:** 3-4 hours