<?php

namespace Modules\Lpj\Emails;

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

class SendJadwalKunjunganEmail extends Mailable
{
     /**
     * ID Penilaian.
     *
     * @var string
     */
    public $id;

    /**
     * Waktu Penilaian.
     *
     * @var string
     */
    public $waktu_penilaian;

    /**
     * Deskripsi Penilaian.
     *
     * @var string
     */
    public $deskripsi_penilaian;

    /**
     * Create a new message instance.
     *
     * @param array $emailData
     * @return void
     */
    public function __construct(array $emailData)
    {
        // Validasi data yang diterima
        if (!isset($emailData['emailData']['id']) ||
            !isset($emailData['emailData']['waktu_penilaian']) ||
            !isset($emailData['emailData']['deskripsi_penilaian'])) {
            throw new \InvalidArgumentException("Data email tidak lengkap.");
        }

        $this->id = $emailData['emailData']['id'];
        $this->waktu_penilaian = $emailData['emailData']['waktu_penilaian'];
        $this->deskripsi_penilaian = $emailData['emailData']['deskripsi_penilaian'];
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Jadwal Kunjungan Penilaian Resmi')
                   ->view('lpj::emails.jadwal-kunjungan');
    }
}
