mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-12 23:27:48 +00:00
32 lines
708 B
JavaScript
32 lines
708 B
JavaScript
import { Controller } from "stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["checkout", "guest"];
|
|
static values = {
|
|
distributor: String,
|
|
session: { type: String, default: "guest-checkout" }
|
|
};
|
|
|
|
connect() {
|
|
if(!this.hasGuestTarget) { return }
|
|
|
|
if(this.usingGuestCheckout()) {
|
|
this.showCheckout();
|
|
}
|
|
}
|
|
|
|
showCheckout() {
|
|
this.checkoutTarget.style.display = "block";
|
|
this.guestTarget.style.display = "none";
|
|
}
|
|
|
|
guestSelected() {
|
|
this.showCheckout();
|
|
sessionStorage.setItem(this.sessionValue, this.distributorValue);
|
|
}
|
|
|
|
usingGuestCheckout() {
|
|
return sessionStorage.getItem(this.sessionValue) === this.distributorValue
|
|
}
|
|
}
|