<?php

namespace App\Mail\InvoiceMails;

use App\Models\CostUnit;
use App\Models\Invoice;
use App\ValueObjects\Amount;
use Illuminate\Mail\Mailable;
use Illuminate\Mail\Mailables\Attachment;
use Illuminate\Mail\Mailables\Content;
use Illuminate\Mail\Mailables\Envelope;

class InvoiceMailsSubmittedConfirmationMail extends Mailable {
    public function __construct(
        private Invoice $invoice,
        private CostUnit $costUnit,
    )
    {
        //
    }

    public function envelope(): Envelope
    {
        return new Envelope(
            subject: 'Deine Abrechnung wurde erfolgreich eingereicht',
        );
    }

    public function content(): Content
    {
        return new Content(
            view: 'emails.invoices.submitted_confirmation',
            with: [
                'contactName' => $this->invoice->contact_name,
                'costUnitName' => $this->costUnit->name,
                'invoiceAmount' => Amount::fromString($this->invoice->amount)->toString(),
                'invoiceType' => $this->invoice->invoiceType()->name,
                'invoiceNumber' => $this->invoice->invoice_number,
            ],
        );
    }

    /**
     * @return array<int, Attachment>
     */
    public function attachments(): array
    {
        return [];
    }
}
