<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;

class InvitationNotification extends Notification
{
    use Queueable;

    public function __construct(public string $token)
    {
    }

    public function via(object $notifiable): array
    {
        return ['mail'];
    }

    public function toMail(object $notifiable): MailMessage
    {
        $url = rtrim(config('app.frontend_url'), '/')
            . '/reset-password?token=' . $this->token
            . '&email=' . urlencode($notifiable->email);

        return (new MailMessage)
            ->subject('Undangan Bergabung — Inventory Management System')
            ->greeting('Halo, ' . $notifiable->name)
            ->line('Anda telah diundang untuk bergabung ke Inventory Management System.')
            ->line('Silakan buat password Anda untuk mengaktifkan akun dan mulai login.')
            ->action('Buat Password', $url)
            ->line('Link ini berlaku selama 24 jam. Jika Anda tidak merasa mendaftar, abaikan email ini.');
    }
}
