<?php

use App\Browser\Jobs\InstagramRepost\InstagramNotificationHandlingJob;
use App\Http\Controllers\JobController;
use App\Models\Job;
use App\Services\BrowserJobsInstances;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::get('/jobs', function (Request $request) {
    return response()->json(Job::all())->header('Cache-Control', 'public, max-age=30');
});

Route::get('/test/{id}', function (Request $request, $id, BrowserJobsInstances $BrowserJobsInstances) {
    $log = $BrowserJobsInstances->getJobInstance($id)->execute();
    dump($log);
    dump(response()->json(['message' => 'Job ' . $id . ' ran', 'jobRun' => $log->load('artifacts')]));
});

Route::get('jobs/{job}/test', [JobController::class, 'test'])->name('jobs.test');

Route::get('/testInstagramNotification', function (Request $request, BrowserJobsInstances $BrowserJobsInstances) {
    $id = 4;
    $job = new InstagramNotificationHandlingJob($id);
    $log = $job->execute();
    dump($log);
    dump(response()->json(['message' => 'Job ' . $id . ' ran', 'jobRun' => $log->load('artifacts')]));
});

