<?php

namespace App\Http\Controllers\ESign;

use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Symfony\Component\HttpFoundation\Response;

class EsignController extends Controller
{
    public function dashboard(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.dashboard'));
        }

        return view('esign.dashboard');
    }

    public function create(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.create'));
        }

        return view('esign.create');
    }

    public function detail(Request $request, int $id): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.detail', $id));
        }

        return view('esign.detail', ['contractId' => $id]);
    }

    public function fields(Request $request, int $id): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.fields', $id));
        }

        return view('esign.fields', ['contractId' => $id]);
    }

    public function send(Request $request, int $id): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.send', $id));
        }

        return view('esign.send', ['contractId' => $id]);
    }

    public function templateFields(Request $request, int $templateId): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.template-fields', $templateId));
        }

        return view('esign.template-fields', ['templateId' => $templateId]);
    }

    public function templates(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.templates'));
        }

        return view('esign.templates');
    }

    public function docs(Request $request): View|Response
    {
        if ($request->header('HX-Request')) {
            return response('', 200)->header('HX-Redirect', route('esign.docs'));
        }

        return view('esign.docs');
    }
}
