mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-12 03:50:22 +00:00
The "apply" button is disabled by default. If left enabled, a customer could try to apply an empty voucher, which results in system trying to move to the order summary step, an unexpected behaviour! We only enable the button when something is entered in the input.
23 lines
499 B
JavaScript
23 lines
499 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["button"];
|
|
|
|
connect() {
|
|
// Hacky way to go arount mrjus automatically enabling/disabling form element
|
|
setTimeout(() => {
|
|
if (this.hasButtonTarget) {
|
|
this.buttonTarget.disabled = true;
|
|
}
|
|
}, 100);
|
|
}
|
|
|
|
inputIsChanged(e) {
|
|
if (e.target.value !== "") {
|
|
this.buttonTarget.disabled = false;
|
|
} else {
|
|
this.buttonTarget.disabled = true;
|
|
}
|
|
}
|
|
}
|