<?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 AdminNewUserRegisteredMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(public User $user) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Nuevo usuario registrado',
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'mail.admin.new-user-registered',
            with: [
                'userName' => $this->user->name,
                'userEmail' => $this->user->email,
                'contactNumber' => $this->user->contact_number ?: '—',
                'country' => $this->user->country ?: '—',
                'registeredAt' => $this->user->created_at?->timezone(config('app.timezone'))->format('d/m/Y H:i') ?? '—',
                'actionUrl' => route('admin.users.edit', $this->user, absolute: true),
            ],
        );
    }
}
