<?php

namespace App\Mail;

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

class RanchCostAlertMail 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 costo por kg en ganado activo")
            ->view('emails.ranch.cost_alerts', [
                'report' => $this->report,
            ]);
    }
}
