feat: Facilidades de uso. Limpa formulário após alteração/adição de dados.

This commit is contained in:
lukibeg 2025-12-08 19:29:00 -03:00
parent 5a02a8fd9e
commit f2363c2353
3 changed files with 6 additions and 0 deletions

View File

@ -26,6 +26,8 @@ public function save(ClientService $clientService)
$data = $this->form->all();
$data['name'] = $data['client_name'];
dd($data);
if ($this->form->profile_image_path) {
$path = $this->form->profile_image_path->store('client_logos', 'public');
$data['profile_image_path'] = $path;
@ -37,6 +39,8 @@ public function save(ClientService $clientService)
$this->dispatch('client-added');
$this->dispatch('notify', message: $client->name . ' adicionado com sucesso!');
$this->form->reset();
} catch (\Exception $e) {
$this->dispatch('notify', message: 'Ocorreu um erro inesperado ao salvar. ' . $e->getMessage(), type: 'error');
}

View File

@ -54,6 +54,7 @@ public function edit(ClientService $clientService)
$this->dispatch('client-updated');
$this->dispatch('notify', message: $this->clientForm->client_name . ' atualizado com sucesso!');
$this->clientForm->reset();
} catch (Exception $e) {
$this->dispatch('notify', message: 'Falha na edição: ' . $e->getMessage(), type: 'error');
}

View File

@ -43,6 +43,7 @@ public function editUser(UserService $userService)
$this->dispatch('user-updated');
$this->dispatch('notify', message: $this->userForm->name . ' atualizado com sucesso!');
$this->userForm->reset();
} catch (\Exception $e) {
$this->dispatch('notify', message: 'Falha na edição: ' . $e->getMessage(), type: 'error');
// $this->addError('general', $e->getMessage());