feat: consolidar desenvolvimentos do portal InvestMoz
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Services\OpportunityTechnicalSupport;
|
||||
use App\Services\TechnicalIncidentHandling;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Inertia\Inertia;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
final class TechnicalSupportController extends Controller
|
||||
{
|
||||
public function index(Request $request, OpportunityTechnicalSupport $support): Response
|
||||
{
|
||||
$filters = $request->validate(['page' => ['nullable', 'integer', 'min:1'], 'status' => ['nullable', 'in:all,open,in_progress,resolved'], 'unread' => ['nullable', 'boolean']]);
|
||||
$status = $filters['status'] ?? 'all';
|
||||
$unread = $request->boolean('unread');
|
||||
$incidents = $support->queue($request->user(), $status, $unread);
|
||||
Inertia::encryptHistory();
|
||||
|
||||
return tap(Inertia::render('profiles/technical-support', ['actorId' => $request->user()->id, 'incidents' => $incidents, 'filters' => ['status' => $status, 'unread' => $unread]])->toResponse($request), static fn (Response $response) => $response->headers->set('Cache-Control', 'private, no-store'));
|
||||
}
|
||||
|
||||
public function show(Request $request, string $reference, TechnicalIncidentHandling $handling, OpportunityTechnicalSupport $support): Response
|
||||
{
|
||||
$filters = $request->validate(['history_page' => ['nullable', 'integer', 'min:1'], 'page' => ['nullable', 'integer', 'min:1'], 'status' => ['nullable', 'in:all,open,in_progress,resolved'], 'unread' => ['nullable', 'boolean']]);
|
||||
$data = $handling->detail($request->user(), $reference);
|
||||
Inertia::encryptHistory();
|
||||
|
||||
$query = array_filter(['page' => $request->integer('page') > 1 ? $request->integer('page') : null, 'status' => ($filters['status'] ?? 'all') !== 'all' ? $filters['status'] : null, 'unread' => $request->boolean('unread') ? 1 : null], fn ($v) => $v !== null);
|
||||
|
||||
return tap(Inertia::render('profiles/technical-incident', [...$data, 'notice' => $support->notice($request->user(), $reference), 'backUrl' => '/suporte-tecnico/incidentes'.($query !== [] ? '?'.http_build_query($query) : '')])->toResponse($request), static fn (Response $response) => $response->headers->set('Cache-Control', 'private, no-store'));
|
||||
}
|
||||
|
||||
public function decide(Request $request, string $reference, TechnicalIncidentHandling $handling): JsonResponse
|
||||
{
|
||||
return response()->json($handling->decide($request->user(), $reference, $request->all()))->header('Cache-Control', 'private, no-store');
|
||||
}
|
||||
|
||||
public function consulted(Request $request, string $reference, OpportunityTechnicalSupport $support): JsonResponse
|
||||
{
|
||||
return response()->json($support->markConsulted($request->user(), $reference))->header('Cache-Control', 'private, no-store');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user