<?php

namespace App\Domains\Admin\Controllers;

use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressAction;
use App\Domains\Admin\Actions\UpdateTenantImpress\UpdateTenantImpressRequest;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class ManagedTenantImpressUpdateController extends CommonController
{
    public function __invoke(string $slug, Request $request): JsonResponse
    {
        $tenant = $this->adminTenants->findBySlug($slug);

        $action = new UpdateTenantImpressAction(new UpdateTenantImpressRequest(
            tenant: $tenant,
            impressText: $request->input('impress_text'),
        ));

        $response = $action->execute();

        return response()->json([
            'status' => $response->success ? 'success' : 'error',
            'message' => $response->message,
        ]);
    }
}
