<?php

namespace App\Services\Forms\Feedback;

use App\Events\FeedbackSender;
use App\Models\Asset;
use App\Models\Dictionaries\Dictionary;
use App\Models\Objects\FieldType;
use App\Models\Objects\NirObject;
use App\Models\Objects\ObjectType;
use App\Models\Registries\Entry;
use App\Models\Registries\Operation;
use App\Models\Registries\OperationType;
use App\Services\Forms\FormsService;
use App\Transformers\Assets\AssetTransformer;
use App\Transformers\Dictionaries\DictionaryItemTransformer;
use App\Transformers\Objects\FieldTransformer;
use App\Transformers\Objects\ObjectPropertyTransformer;
use App\Transformers\Objects\ObjectTransformer;
use App\Transformers\Registries\OperationTransformer;
use Illuminate\Http\JsonResponse;

class FeedbackForms extends FormsService {
    public array $formTitles = ['create' => 'Создание операции', 'update' => 'Редактирование операции'];

    public function form(?string $id = null, array $data = []): array {
        $model = NirObject::byUuid($id)->first();
        $groups = [
            ['name' => 'common', 'fields' => $this->commonGroupFields($model)]
        ];
        return ['title' => $this->formTitle($model), 'data' => $groups];
    }

    public function commonGroupFields(?NirObject $model): array {
        return [];
    }


    public function store(array $data) {
        var_dump($data);
        $email = 'sergey@bodin.ru';
        event(new FeedbackSender($email, $data));
        return null;
    }

    public function update(string $id, array $data) {
        return null;
    }
}
