<?php

namespace App\Notifications;

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

class PromotedToPrimaryBuyer extends Notification implements ShouldQueue
{
    use Queueable;

    public function __construct(
        private Item $item
    ) {
    }

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

    public function toMail(object $notifiable): MailMessage
    {
        return (new MailMessage)
            ->subject("You're Now the Primary Buyer: {$this->item->title}")
            ->greeting('Good news!')
            ->line("A buyer ahead of you stepped aside, so you're now the primary buyer for \"{$this->item->title}\".")
            ->line('The seller will contact you to arrange payment and delivery.')
            ->action('View Item', route('items.show', $this->item))
            ->line('If you are no longer interested, please withdraw from the queue so the seller can move on.');
    }
}
