<?php

namespace App\Listeners;

use App\Events\OrderConfirmed;
use App\Services\SmsNotificationService;
use Illuminate\Contracts\Queue\ShouldQueue;

class SendOrderConfirmationSms implements ShouldQueue
{
    /**
     * Create the event listener.
     */
    public function __construct(
        protected SmsNotificationService $smsService,
    ) {}

    /**
     * Handle the event.
     */
    public function handle(OrderConfirmed $event): void
    {
        $order = $event->order;
        
        // Only send SMS if customer has mobile
        if ($order->user && $order->user->mobile) {
            $this->smsService->sendOrderConfirmation($order);
        }
    }
}
