<?php

namespace App\Mail;

use App\Models\Folder;
use App\Models\FolderInvitation;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class FolderConfirmationMail extends Mailable
{
    use Queueable, SerializesModels;

    /**
     * Create a new message instance.
     */
    public function __construct(
        public Folder $folder,
        public FolderInvitation $invitation,
        public string $body
    ) {}

    /**
     * Get the message envelope.
     */
    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Demande de validation - '.$this->folder->title,
        );
    }

    /**
     * Get the message content definition.
     */
    public function content(): Content
    {
        return new Content(
            markdown: 'emails.folder-confirmation',
            with: [
                'folderTitle' => $this->folder->title,
                'body' => $this->body,
                'confirmUrl' => route('client.confirm', ['token' => $this->invitation->token]),
                'refuseUrl' => route('client.refuse', ['token' => $this->invitation->token]),
                'expiresAt' => $this->invitation->expires_at->format('d/m/Y à H:i'),
            ]
        );
    }
}
