<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class RanchWeightAlertMail extends Mailable
{
    use Queueable;
    use SerializesModels;

    /**
     * @param  array<string, mixed>  $report
     */
    public function __construct(
        public readonly array $report,
    ) {}

    public function build(): self
    {
        $count = $this->report['alert_count'] ?? 0;
        $empresa = config('app.name', 'Control Ganadero');

        return $this->subject("{$empresa}: {$count} alerta(s) de peso en el rancho")
            ->view('emails.ranch.weight_alerts', [
                'report' => $this->report,
            ]);
    }
}
