Files
openfoodnetwork/app/webpacker/js/turbo.js
David Cook 876d37d19a Fix function call
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 🤦
2026-02-02 17:08:24 +11:00

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();
}
});