Skip to content

Commit

Permalink
Clean up hardcoded values and improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
wandji20 committed Sep 3, 2024
1 parent de6426c commit 481e9d8
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions app/webpacker/controllers/guest_checkout_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default class extends Controller {
}
}

disconnect() {
this.removeUnloadEvent();
}

login() {
window.dispatchEvent(new Event("login:modal:open"));
}
Expand All @@ -40,19 +44,13 @@ export default class extends Controller {
}

handlePageUnload(event) {
event.preventDefault()

event.returnValue = 'I18n.t("admin.unsaved_confirm_leave")';
return
event.preventDefault();
event.returnValue = I18n.t("admin.unsaved_confirm_leave");
}

removeUnloadEvent() {
if (this.hasSummaryTarget) {
window.removeEventListener('beforeunload', this.handlePageUnload);
}
}

disconnect() {
this.removeUnloadEvent();
}
}

0 comments on commit 481e9d8

Please sign in to comment.