<?php

namespace App\Http\Controllers;

use App\Http\Resources\UserTypePermissionResource;
use App\Services\UserTypePermissionService;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\Auth;

class UserTypePermissionController extends Controller
{
    public function __construct(
        protected UserTypePermissionService $userTypePermissionService,
    ) {}

    public function allGuestPermissions(): JsonResponse
    {
        $userTypePermission = $this->userTypePermissionService->allGuestPermissions();

        return $this->successResponse(payload: UserTypePermissionResource::collection($userTypePermission));
    }

    public function allPermissionsByUserType(): JsonResponse
    {
        $user = Auth::user();

        $userTypePermission = $this->userTypePermissionService->allPermissionsByUserType($user->type);

        return $this->successResponse(payload: UserTypePermissionResource::collection($userTypePermission));
    }
}
