Files
openfoodnetwork/app/webpacker/controllers/out_of_stock_modal_controller.js
Gaetan Craig-Riou 4a2f22e56d Add OutOfStockModalComponent
It encapsulate the logic for the out of stock modal
2025-02-18 10:47:03 +11:00

20 lines
501 B
JavaScript

import { Controller } from "stimulus";
// This is meant to be used with the "modal:closing" event, ie:
//
// <div data-controller="out-of-stock-modal"
// data-action="moda:closing@out-of-stock-modal#redirect"
// data-out-of-stock-modal-redirect-value="true"
// >
// </div>
//
export default class extends Controller {
static values = { redirect: { type: Boolean, default: false } };
redirect() {
if (this.redirectValue) {
window.location.pathname = "/shop";
}
}
}