<?php

declare(strict_types=1);

namespace Seka\Portal\Modul\Terminy\Mail\Registracia;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\Str;
use Seka\Portal\Modul\Terminy\Entities\Dtos\RegistraciaDTO;

/**
 * Class VytvorenaRegistraciaNaUdalostMail
 *
 * @package Seka\Portal\Modul\Terminy\Mail\Registracia
 */
final class VytvorenaRegistraciaNaUdalostMail extends Mailable implements ShouldQueue
{
    use Queueable;
    use SerializesModels;

    /**
     * @var \Seka\Portal\Modul\Terminy\Entities\Dtos\RegistraciaDTO
     */
    public RegistraciaDTO $registracia;

    /**
     * @param \Seka\Portal\Modul\Terminy\Entities\Dtos\RegistraciaDTO $registracia
     */
    public function __construct(RegistraciaDTO $registracia)
    {
        $this->registracia = $registracia;
    }

    public function build()
    {
        $urlRegistraciiPouzivatela = URL::signedRoute('modul.terminy.frontend.registracie.pouzivatel.index');

        return $this
            ->subject(sprintf('Potvrdenie registrácie na udalosť - %s', Str::ucfirst($this->registracia->udalost->nazov)))
            ->markdown('Terminy::mail.registracia.public.vytvorena')
            ->withRegistracia($this->registracia)
            ->withUrlRegistracii($urlRegistraciiPouzivatela)
            ->replyTo(config('terminy.podpora.email'));
    }
}
