<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class SupportRequestSubmitted extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        public string $name,
        public string $email,
        public string $reason,
        public string $message,
    ) {}

    public function via($notifiable): array
    {
        return ['mail'];
    }

    public function toMail($notifiable): MailMessage
    {
        return (new MailMessage)
            ->theme('flightsgoneby')
            ->subject('New Support Request: ' . $this->reasonLabel())
            ->replyTo($this->email, $this->name)
            ->greeting('New Support Request')
            ->line('Reason: ' . $this->reasonLabel())
            ->line('From: ' . $this->name . ' (' . $this->email . ')')
            ->line($this->message);
    }

    protected function reasonLabel(): string
    {
        return match ($this->reason) {
            'bug_report' => 'Bug Report',
            'general_feedback' => 'General Feedback',
            'missing_data' => 'Missing Data',
            default => $this->reason,
        };
    }
}
