<?php

namespace App\Mail;

use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class AdminKycSubmittedMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(public User $user) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Nueva solicitud de verificación KYC',
        );
    }

    public function content(): Content
    {
        $profile = $this->user->kycProfile;

        return new Content(
            markdown: 'mail.admin.kyc-submitted',
            with: [
                'userName' => $this->user->name,
                'userEmail' => $this->user->email,
                'legalName' => $profile === null
                    ? '—'
                    : trim($profile->legal_first_name.' '.$profile->legal_last_name),
                'documentType' => $profile?->documentTypeLabel() ?? '—',
                'documentNumber' => $profile?->document_number ?? '—',
                'issuingCountry' => $profile?->document_issuing_country ?? '—',
                'residenceCountry' => $profile?->country_of_residence ?? '—',
                'actionUrl' => route('admin.kyc.detail', $this->user, absolute: true),
            ],
        );
    }
}
