<?php

namespace App\Http\Controllers\Api\V1\Admin\Reports;

use App\Http\Controllers\Controller;
use App\Models\ReportJob;
use App\Support\ApiResponse;
use Illuminate\Http\JsonResponse;

/** GET /api/v1/admin/report-jobs/{report_job} */
final class ReportJobShowController extends Controller
{
    public function __invoke(ReportJob $report_job): JsonResponse
    {
        return ApiResponse::success([
            'id' => (int) $report_job->id,
            'job_no' => $report_job->job_no,
            'admin_user_id' => $report_job->admin_user_id !== null ? (int) $report_job->admin_user_id : null,
            'report_type' => $report_job->report_type,
            'export_format' => $report_job->export_format,
            'status' => $report_job->status,
            'finished_at' => $report_job->finished_at?->toIso8601String(),
            'created_at' => $report_job->created_at?->toIso8601String(),
        ]);
    }
}
