<?php

namespace App\Notifications;

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\WebPush\WebPushChannel;
use NotificationChannels\WebPush\WebPushMessage;

class DailySummaryNotification extends Notification
{
    use Queueable;

    public function __construct(
        public string $date,
        public int $totalAppointments
    ) {}

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

    public function toWebPush(object $notifiable, Notification $notification): WebPushMessage
    {
        $msg = $this->totalAppointments === 0
            ? "No hay citas programadas para hoy ({$this->date})."
            : "Resumen del día: {$this->totalAppointments} cita(s) programada(s) para hoy ({$this->date}).";

        return (new WebPushMessage)
            ->title('Resumen diario - Barbería')
            ->body($msg)
            ->icon('/logo.png')
            ->data(['date' => $this->date, 'type' => 'daily_summary']);
    }
}
