<?php

namespace App\Domains\CostUnit\Controllers;

use App\Providers\InertiaProvider;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ListController extends CommonController {
    public function __invoke() {
        $inertiaProvider = new InertiaProvider('CostUnit/List', [
            'cost_unit_id' => 1
        ]);
        return $inertiaProvider->render();
    }

    public function listCurrentEvents(Request $request) : JsonResponse {

        return response()->json([
            'cost_unit_title' => 'Aktuelle Veranstaltungen',
            'cost_units' => $this->costUnits->getCurrentEvents(),
        ]);
    }

    public function listCurrentRunningJobs(Request $request) : JsonResponse {
        return response()->json([
            'cost_unit_title' => 'Laufende Tätigkeiten',
            'cost_units' => $this->costUnits->getRunningJobs(),
        ]);
    }

    public function listClosedCostUnits(Request $request) : JsonResponse {
        return response()->json([
            'cost_unit_title' => 'Geschlossene Kostenstellen',
            'cost_units' => $this->costUnits->getClosedCostUnits(),
        ]);
    }

    public function listArchivedCostUnits(Request $request) : JsonResponse {
        return response()->json([
            'cost_unit_title' => 'Archivierte Kostenstellen',
            'cost_units' => $this->costUnits->getArchivedCostUnits(),
        ]);
    }


}
