Files
karczma-aplikacja-stoliki/public/assets/js/app.js
T

116 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 {
getHashParam,
setHashParam,
setIsStaffPreview,
setTableParam,
} from "./modules/state.js";
import { showToast } from "./modules/toast.js";
// Parse URL into shared state
const params = new URLSearchParams(location.search);
setHashParam((params.get("h") || "").trim());
setIsStaffPreview(params.get("preview") === "staff");
setTableParam(""); // Puste, zostanie uzupełnione przez backend
// Jeśli brak hasha w URL – zapytaj użytkownika (np. do testów)
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.* for inline onclick in app.php
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();