138 lines
3.6 KiB
JavaScript
138 lines
3.6 KiB
JavaScript
import { trackEvent } from "./modules/analytics.js";
|
|
import {
|
|
promptGeoForFullAccess,
|
|
setProtectedActionHandlers,
|
|
switchTab,
|
|
} from "./modules/access.js";
|
|
import {
|
|
callWaiter,
|
|
closeBillDialog,
|
|
closeWaiterDialog,
|
|
confirmCallWaiter,
|
|
confirmInvoice,
|
|
editCompanyData,
|
|
fetchGUS,
|
|
goBackToBillList,
|
|
goToStep,
|
|
openBillDialog,
|
|
openBillDialogInternal,
|
|
openWaiterDialog,
|
|
openWaiterDialogInternal,
|
|
proceedToBillPayment,
|
|
selectDocument,
|
|
selectPayment,
|
|
showBillReview,
|
|
} from "./modules/bill.js";
|
|
import {
|
|
bindItemModalSwipe,
|
|
closeItemModal,
|
|
filterMenu,
|
|
handleMenuImageError,
|
|
loadMenu,
|
|
navigateItemModal,
|
|
openItemModal,
|
|
showCategory,
|
|
} from "./modules/menu.js";
|
|
import { clearGlobalHistory } from "./modules/orders.js";
|
|
import {
|
|
declineUserName,
|
|
enterMenuOnlyMode,
|
|
handleGeoMenuClick,
|
|
initGeolocation,
|
|
retryGeolocation,
|
|
saveUserName,
|
|
startGeoBootstrap,
|
|
} from "./modules/geo.js";
|
|
import {
|
|
createLanguagePicker,
|
|
initI18n,
|
|
} from "./modules/i18n.js";
|
|
import {
|
|
getHashParam,
|
|
setHashParam,
|
|
setIsStaffPreview,
|
|
setTableParam,
|
|
} from "./modules/state.js";
|
|
import { showToast } from "./modules/toast.js";
|
|
|
|
initI18n();
|
|
|
|
function mountLanguagePickers() {
|
|
const mounts = [
|
|
["geoLangPickerMount", "geoLang"],
|
|
["headerLangPickerMount", "headerLang"],
|
|
["menuLangPickerMount", "menuLang"],
|
|
];
|
|
|
|
mounts.forEach(([mountId, prefix]) => {
|
|
const mount = document.getElementById(mountId);
|
|
if (!mount || mount.dataset.ready) return;
|
|
const picker = createLanguagePicker({ idPrefix: prefix });
|
|
mount.appendChild(picker.el);
|
|
mount.dataset.ready = "1";
|
|
});
|
|
}
|
|
|
|
mountLanguagePickers();
|
|
|
|
// Parse URL into shared state
|
|
const params = new URLSearchParams(location.search);
|
|
setHashParam((params.get("h") || "").trim());
|
|
setIsStaffPreview(params.get("preview") === "staff");
|
|
setTableParam("");
|
|
|
|
if (!getHashParam()) {
|
|
const input = prompt("Podaj bezpieczny hash stolika (wymagane):");
|
|
const trimmed = (input || "").trim();
|
|
if (trimmed) {
|
|
const newUrl = new URL(location.href);
|
|
newUrl.searchParams.set("h", trimmed);
|
|
location.replace(newUrl.toString());
|
|
}
|
|
}
|
|
|
|
setProtectedActionHandlers({
|
|
waiter: openWaiterDialogInternal,
|
|
bill: openBillDialogInternal,
|
|
});
|
|
|
|
window.saveUserName = saveUserName;
|
|
window.declineUserName = declineUserName;
|
|
window.handleGeoMenuClick = handleGeoMenuClick;
|
|
window.retryGeolocation = retryGeolocation;
|
|
window.promptGeoForFullAccess = promptGeoForFullAccess;
|
|
window.enterMenuOnlyMode = enterMenuOnlyMode;
|
|
window.clearGlobalHistory = clearGlobalHistory;
|
|
window.callWaiter = callWaiter;
|
|
window.openWaiterDialog = openWaiterDialog;
|
|
window.closeWaiterDialog = closeWaiterDialog;
|
|
window.confirmCallWaiter = confirmCallWaiter;
|
|
window.proceedToBillPayment = proceedToBillPayment;
|
|
window.openBillDialog = openBillDialog;
|
|
window.goBackToBillList = goBackToBillList;
|
|
window.showBillReview = showBillReview;
|
|
window.closeBillDialog = closeBillDialog;
|
|
window.goToStep = goToStep;
|
|
window.switchTab = switchTab;
|
|
window.filterMenu = filterMenu;
|
|
window.showCategory = showCategory;
|
|
window.selectPayment = selectPayment;
|
|
window.selectDocument = selectDocument;
|
|
window.fetchGUS = fetchGUS;
|
|
window.handleMenuImageError = handleMenuImageError;
|
|
window.navigateItemModal = navigateItemModal;
|
|
window.openItemModal = openItemModal;
|
|
window.closeItemModal = closeItemModal;
|
|
window.editCompanyData = editCompanyData;
|
|
window.confirmInvoice = confirmInvoice;
|
|
window.initGeolocation = initGeolocation;
|
|
window.showToast = showToast;
|
|
|
|
if (getHashParam()) {
|
|
trackEvent("qr_scan", { source: "qr_link_open" });
|
|
}
|
|
|
|
loadMenu();
|
|
bindItemModalSwipe();
|
|
startGeoBootstrap();
|