<?php

namespace App\Domains\Admin\Controllers;

use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprAction;
use App\Domains\Admin\Actions\UpdateTenantGdpr\UpdateTenantGdprRequest;
use App\Scopes\CommonController;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class TenantGdprUpdateController extends CommonController
{
    public function __invoke(Request $request): JsonResponse
    {
        $action = new UpdateTenantGdprAction(new UpdateTenantGdprRequest(
            tenant: $this->tenant,
            gdprText: $request->input('gdpr_text'),
        ));

        $response = $action->execute();

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