working on modal
This commit is contained in:
@@ -2,41 +2,83 @@ import { useNavigate } from "react-router-dom";
|
||||
|
||||
/**
|
||||
* Custom hook to provide navigation functions.
|
||||
* @param {string} params - The shop ID for constructing URLs.
|
||||
* @param {string} shopId - The shop ID for constructing URLs.
|
||||
* @returns {Object} - Navigation functions.
|
||||
*/
|
||||
export const useNavigationHelpers = (params) => {
|
||||
export const useNavigationHelpers = (shopId, tableId) => {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const goToLogin = () => {
|
||||
if (params) navigate(`/login?next=${params}`);
|
||||
else navigate(`/login`);
|
||||
// Construct the base URL
|
||||
let url = "/login";
|
||||
|
||||
// Append query parameters conditionally
|
||||
const queryParams = new URLSearchParams();
|
||||
if (shopId) queryParams.append("next", shopId);
|
||||
if (tableId) queryParams.append("table", tableId);
|
||||
|
||||
// Set the URL with query parameters
|
||||
if (queryParams.toString()) {
|
||||
url += `?${queryParams.toString()}`;
|
||||
}
|
||||
|
||||
// Perform the navigation
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToShop = () => {
|
||||
navigate(`/${params}/`);
|
||||
// Construct the base URL for the shop
|
||||
let url = `/${shopId}`;
|
||||
|
||||
// Append the tableId if it's provided
|
||||
if (tableId) {
|
||||
url += `/${tableId}`;
|
||||
}
|
||||
|
||||
// Perform the navigation
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToSearch = () => {
|
||||
navigate(`/${params}/search`);
|
||||
let url = `/${shopId}`;
|
||||
if (tableId) {
|
||||
url += `/${tableId}`;
|
||||
}
|
||||
url += "/search";
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToCart = () => {
|
||||
navigate(`/${params}/cart`);
|
||||
let url = `/${shopId}`;
|
||||
if (tableId) {
|
||||
url += `/${tableId}`;
|
||||
}
|
||||
url += "/cart";
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToInvoice = (orderType, tableNumber, email) => {
|
||||
if (orderType === "serve" && tableNumber) {
|
||||
navigate(
|
||||
`/${params}/invoice?orderType=${orderType}&tableNumber=${tableNumber}&email=${email}`,
|
||||
);
|
||||
} else {
|
||||
navigate(`/${params}/invoice?orderType=${orderType}&email=${email}`);
|
||||
let url = `/${shopId}`;
|
||||
if (tableId) {
|
||||
url += `/${tableId}`;
|
||||
}
|
||||
url += `/invoice?orderType=${orderType}`;
|
||||
if (tableNumber) {
|
||||
url += `&tableNumber=${tableNumber}`;
|
||||
}
|
||||
if (email) {
|
||||
url += `&email=${email}`;
|
||||
}
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToGuestSideLogin = () => {
|
||||
navigate(`/${params}/guest-side-login`);
|
||||
let url = `/${shopId}`;
|
||||
if (tableId) {
|
||||
url += `/${tableId}`;
|
||||
}
|
||||
url += "/guest-side-login";
|
||||
navigate(url);
|
||||
};
|
||||
|
||||
const goToAdminCafes = () => {
|
||||
|
||||
Reference in New Issue
Block a user