<?php

namespace Modules\MembershipApplication\Emails;

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

class MembershipApplicationSubmittedNotification extends Notification
{
    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 (new MailMessage)
            ->subject('Pengesahan Permohonan Keahlian')
            ->markdown('membershipapplication::emails.submitted', [
                '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',
                ],
                'logoPath' => public_path('images/logo-kopkb.svg'),
            ]);
    }
}
