mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
since jsdom 21, it's no longer possible to mock window.location See : https://github.com/jsdom/jsdom/issues/3492
21 lines
555 B
JavaScript
21 lines
555 B
JavaScript
import { Controller } from "stimulus";
|
|
import { locationPathName } from "js/window_location_wrapper";
|
|
|
|
// 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) {
|
|
locationPathName("/shop");
|
|
}
|
|
}
|
|
}
|