<?php

namespace App\Mail;

use App\Models\ScheduledVisit;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class VisitScheduledMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public ScheduledVisit $visit,
        public string $type = 'scheduled' // 'scheduled' | 'reminder'
    ) {}

    public function envelope(): Envelope
    {
        $subject = $this->type === 'reminder'
            ? 'Reminder: Visit scheduled for today - ' . $this->visit->scheduled_date
            : 'New visit assigned to you - ' . $this->visit->scheduled_date;

        return new Envelope(
            subject: $subject,
            from: config('mail.from.address'),
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.visit-scheduled',
        );
    }
}
