mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-18 00:17:25 +00:00
This function got renamed in 01d5830480, but this call got missed.
I would like to add a spec to cover this, but am not sure exactly how to set it up right now.
I also notice that usage occurs after the preventDefault, and one before. I'm not sure if that matters. I have myself to blame for that inconsistency 🤦
22 lines
596 B
JavaScript
22 lines
596 B
JavaScript
import "@hotwired/turbo";
|
|
import showHttpError from "./services/show_http_error";
|
|
|
|
import TurboPower from "turbo_power";
|
|
TurboPower.initialize(Turbo.StreamActions);
|
|
|
|
document.addEventListener("turbo:frame-missing", (event) => {
|
|
// don't replace frame contents
|
|
event.preventDefault();
|
|
|
|
// show error message instead
|
|
showHttpError(event.detail.response?.status);
|
|
});
|
|
|
|
document.addEventListener("turbo:submit-end", (event) => {
|
|
if (!event.detail.success) {
|
|
// show error message on failure
|
|
showHttpError(event.detail.fetchResponse?.statusCode);
|
|
event.preventDefault();
|
|
}
|
|
});
|