<?php

namespace App\Mail;

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

/**
 * Sent when a new user is created (invited).
 * Contains a one-time setup link for them to set their password and 2FA.
 */
class UserWelcome extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(
        public User $user,
        public string $setupUrl,
        public string $invitedBy
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: '[HostSeba NOC] You\'ve been invited',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.user-welcome',
            with: [
                'name' => $this->user->name,
                'email' => $this->user->email,
                'role' => $this->user->role,
                'setupUrl' => $this->setupUrl,
                'invitedBy' => $this->invitedBy,
                'appName' => config('app.name', 'HostSeba NOC'),
            ],
        );
    }
}
