<?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;

    public RegistraciaDTO $registracia;

    public function __construct(RegistraciaDTO $registracia)
    {
        $this->registracia = $registracia;
    }

    /**
     * @throws \Illuminate\Contracts\Container\BindingResolutionException
     * @throws \Psr\Container\ContainerExceptionInterface
     * @throws \Psr\Container\NotFoundExceptionInterface
     */
    public function build(): mixed
    {
        $urlRegistraciiPouzivatela = URL::signedRoute('modul.terminy.frontend.registracie.pouzivatel.index');

        return $this
            ->subject(
                sprintf(
                    'Potvrdenie vytvorenia 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'));
    }
}
