<?php

namespace App\Notifications;

use App\Models\CompanyRegistration;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class CompanyRegistrationRejectedNotification extends Notification implements ShouldQueue
{
    use Queueable;

    /**
     * Create a new notification instance.
     */
    public function __construct(
        public CompanyRegistration $submission
    ) {}

    /**
     * Get the notification's delivery channels.
     *
     * @return array<int, string>
     */
    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    /**
     * Get the mail representation of the notification.
     */
    public function toMail(object $notifiable): MailMessage
    {
        $message = (new MailMessage)
            ->subject('KYC Submission Status - InsureData')
            ->greeting('Dear ' . $this->submission->company_name . ',')
            ->line('Thank you for your interest in InsureData.')
            ->line('After careful review, we regret to inform you that your Corporate KYC registration submission has not been approved at this time.');

        if ($this->submission->rejection_reason) {
            $message->line('**Reason:**')
                ->line($this->submission->rejection_reason);
        }

        $message->line('If you believe this decision was made in error or if you would like to submit a new application with updated information, please contact our support team.')
            ->line('We appreciate your understanding.');

        return $message;
    }

    /**
     * Get the array representation of the notification.
     *
     * @return array<string, mixed>
     */
    public function toArray(object $notifiable): array
    {
        return [
            'submission_id' => $this->submission->id,
            'company_name' => $this->submission->company_name,
            'rejection_reason' => $this->submission->rejection_reason,
        ];
    }
}
