libra/docs/stories/story-8.4-booking-approved-...

1.8 KiB

Story 8.4: Booking Approved Email

Epic Reference

Epic 8: Email Notification System

User Story

As a client, I want to receive notification when my booking is approved, So that I can confirm the appointment and add it to my calendar.

Acceptance Criteria

Trigger

  • Sent on booking approval by admin

Content

  • "Your consultation has been approved"
  • Confirmed date and time
  • Duration (45 minutes)
  • Consultation type (free/paid)
  • If paid: amount and payment instructions
  • .ics calendar file attached
  • "Add to Calendar" button
  • Location/contact information

Language

  • Email in client's preferred language

Attachment

  • Valid .ics calendar file

Technical Notes

class BookingApprovedEmail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public Consultation $consultation,
        public string $icsContent,
        public ?string $paymentInstructions = null
    ) {}

    public function content(): Content
    {
        $locale = $this->consultation->user->preferred_language ?? 'ar';

        return new Content(
            markdown: "emails.booking.approved.{$locale}",
            with: [
                'consultation' => $this->consultation,
                'paymentInstructions' => $this->paymentInstructions,
            ],
        );
    }

    public function attachments(): array
    {
        return [
            Attachment::fromData(fn() => $this->icsContent, 'consultation.ics')
                ->withMime('text/calendar'),
        ];
    }
}

Definition of Done

  • Email sent on approval
  • All details included
  • Payment info for paid consultations
  • .ics file attached
  • Bilingual templates
  • Tests pass

Estimation

Complexity: Medium | Effort: 3 hours