<?php

namespace App\Mail;

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

class RanchOpenLotsGdpAlertMail extends Mailable
{
    use Queueable;
    use SerializesModels;

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

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

        return $this->subject("{$empresa}: {$lotsCount} lote(s) de engorda con GDP bajo meta")
            ->view('emails.ranch.open_lots_gdp_alerts', [
                'report' => $this->report,
            ]);
    }
}
