Rename command controller => terminal controller and name the error class after terminal

This commit is contained in:
Jorge Manrubia
2025-05-07 08:53:25 +02:00
parent 55ea460d3e
commit 6f382b68e0
4 changed files with 6 additions and 6 deletions
@@ -0,0 +1,26 @@
import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = [ "input" ]
static classes = [ "error" ]
// Actions
focus() {
this.inputTarget.focus()
}
handleSubmit(event) {
if (event.detail.success) {
event.target.reset()
} else {
this.#handleErrorResponse(event.detail.fetchResponse.response.status)
}
}
#handleErrorResponse(code) {
if (code == 422) {
this.element.classList.add(this.errorClass)
}
}
}