mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-23 05:28:53 +00:00
Checkout payment page, enable voucher "apply" button when code entered
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.
This commit is contained in:
committed by
Maikel Linke
parent
e5f14177d3
commit
aa526a639c
@@ -0,0 +1,22 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user