<?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 TenantImpressUpdateController extends CommonController
{
    public function __invoke(Request $request): JsonResponse
    {
        $action = new UpdateTenantImpressAction(new UpdateTenantImpressRequest(
            tenant: $this->tenant,
            impressText: $request->input('impress_text'),
        ));

        $response = $action->execute();

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