<?php

namespace App\Mail;

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

class CustomerComplaintResponseMail extends Mailable
{
    use Queueable;
    use SerializesModels;

    public function __construct(public OrderComplaint $complaint)
    {
        $this->complaint->loadMissing(['customer', 'order', 'product']);
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: "Complaint response: {$this->complaint->order->order_number}"
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.customer-complaint-response',
            with: ['complaint' => $this->complaint]
        );
    }
}
