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

    public function build()
    {
        $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'));
    }
}
