<?php

namespace App\Services\DecisionEvents\Handlers;

use App\Models\CallLater;
use App\Services\DecisionEvents\Contracts\DecisionEventHandler;
use App\Services\DecisionEvents\DecisionEventContext;

class CallLaterHandler implements DecisionEventHandler
{
    public function handle(DecisionEventContext $context, array $config = []): void
    {
        $activity = $context->activity;

        if (empty($activity->call_back_at)) {
            return;
        }

        CallLater::create([
            'activity_id' => $activity->id,
            'client_case_id' => $activity->client_case_id,
            'contract_id' => $activity->contract_id,
            'user_id' => $activity->user_id,
            'call_back_at' => $activity->call_back_at,
        ]);
    }
}
