<?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 ZrusenaRegistraciaNaUdalostMail
 *
 * @package Seka\Portal\Modul\Terminy\Mail\Registracia
 */
final class ZrusenaRegistraciaNaUdalostMail 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;
    }

    /**
     * @return mixed
     * @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('Zrušenie registrácie na udalosť - %s', Str::ucfirst($this->registracia->udalost->nazov)))
            ->markdown('Terminy::mail.registracia.public.zrusena')
            ->withRegistracia($this->registracia)
            ->withUrlRegistracii($urlRegistraciiPouzivatela)
            ->replyTo(config('terminy.podpora.email'));
    }
}
