<?php

namespace App\Mail;

use App\Models\Declaration;
use App\Models\User;
use Illuminate\Bus\Queueable;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;
use Illuminate\Queue\SerializesModels;

class NudgeNotificationMail extends Mailable
{
    use Queueable, SerializesModels;

    public function __construct(
        public Declaration $declaration,
        public User $sender,
    ) {}

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Relance - '.($this->declaration->title ?? 'Sans titre'),
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'emails.nudge-notification',
            with: [
                'senderName' => $this->sender->name,
                'clientName' => $this->declaration->client?->name,
                'declarationType' => $this->declaration->type?->value,
                'dueDate' => $this->declaration->due_date?->format('d/m/Y'),
                'url' => route('declarations.show', $this->declaration),
                'firmName' => $this->declaration->workspace?->name,
            ]
        );
    }
}
