<?php

namespace App\Mail;

use App\Models\User;
use App\Services\PlanFeatures;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

final class PaymentFailedDay5Reminder extends Mailable
{
    public function __construct(public readonly User $user) {}

    public function envelope(): Envelope
    {
        $tier = PlanFeatures::for($this->user)->tier();

        return new Envelope(
            subject: 'Last chance — your '.ucfirst($tier).' features end tomorrow',
        );
    }

    public function content(): Content
    {
        return new Content(
            markdown: 'emails.payment-failed-day-5',
            with: [
                'name' => $this->user->name,
                'tier' => PlanFeatures::for($this->user)->tier(),
                'portalUrl' => route('billing.portal'),
            ],
        );
    }
}
