<?php

declare(strict_types=1);

namespace App\Mail;

use App\Domain\Account\Models\Account;
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;

class WelcomeNewAccount extends Mailable implements ShouldQueue
{
    use Queueable, SerializesModels;

    public function __construct(
        public readonly Account $account,
        public readonly string $temporaryPassword = '',
        public readonly ?string $cpUrl = null,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: "Onoxsoft'a Hoş Geldiniz — Hesabınız Hazır",
            tags: ['account', 'welcome'],
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.account.welcome',
            with: [
                'account' => $this->account,
                'temporaryPassword' => $this->temporaryPassword,
                'cpUrl' => $this->cpUrl ?? config('app.url').'/panel',
                'username' => $this->account->username,
                'primaryDomain' => $this->account->primary_domain ?? '—',
            ],
        );
    }
}
