<?php

namespace App\Mail;

use App\Facades\Settings;
use App\Traits\GetsColourSettings;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Collection;

class AutoTraderLocationAccessFailedMail extends Mailable
{
    use Queueable;
    use SerializesModels;
    use GetsColourSettings;

    /**
     * @param Collection $locations Failing AutoTraderLocationStatus records.
     * @param bool $isLive Whether the tenant site is live.
     */
    public function __construct(
        private readonly Collection $locations,
        private readonly bool $isLive
    ) {
    }

    /**
     * Build the message.
     *
     * @return \Illuminate\Mail\Mailable
     */
    public function build()
    {
        return $this->subject('AutoTrader stock access failure')
            ->view('emails.alerts.auto-trader-location-access')
            ->with([
                'locations' => $this->locations,
                'isLive' => $this->isLive,
                'site_name' => Settings::get('app-name') ?? config('app.name'),
                'site_logo' => Settings::get('site-logo'),
                'colours' => $this->getColourSettings(),
            ]);
    }
}
