<?php

namespace App\Observers;

use App\Enums\TimelineStatus;
use App\Mail\TimelineUpdateEmail;
use App\Models\TimelineUpdate;
use Illuminate\Support\Facades\Mail;

class TimelineUpdateObserver
{
    public function created(TimelineUpdate $update): void
    {
        // Only send for active timelines
        if ($update->timeline->status !== TimelineStatus::Active) {
            return;
        }

        $client = $update->timeline->user;

        Mail::to($client->email)->queue(
            new TimelineUpdateEmail($update)
        );
    }
}
