<?php

namespace Modules\MembershipApplication\Emails;

use App\Notifications\Concerns\BuildsMailMessage;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
use Modules\MembershipApplication\Entities\MembershipApplication;

class MembershipApplicationSubmittedNotification extends Notification
{
    use BuildsMailMessage;
    use Queueable;

    public function __construct(
        protected MembershipApplication $application
    ) {}

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $this->application->loadMissing(['applicant', 'heirs', 'documents', 'references.member']);

        return $this->mailMessage(
            subject: 'Pengesahan Permohonan Keahlian',
            view: 'membershipapplication::emails.submitted',
            data: [
                'application' => $this->application,
                'applicant' => $this->application->applicant,
                'heirs' => $this->application->heirs,
                'documents' => $this->application->documents,
                'documentLabels' => [
                    'ic_copy' => 'Salinan Kad Pengenalan',
                    'photo' => 'Gambar Passport',
                    'salary_slip' => 'Slip Gaji',
                    'employer_letter' => 'Surat Pengesahan Majikan',
                ],
            ],
        );
    }
}
