Commit c70643c1 by Madhankumar

code optimized

parent 45e53639
{ {
"bookingSeats": [ "seatLayout": [
[ [
0, 0,
"A1", "A1",
...@@ -101,20 +101,24 @@ ...@@ -101,20 +101,24 @@
{ {
"mobile": "9999999997", "mobile": "9999999997",
"id": 3 "id": 3
},
{
"mobile": "3333333333",
"id": 4
} }
], ],
"reservedSeats": [ "reservedSeats": [
{ {
"seats": [ "seats": [
"F4" "H5"
], ],
"id": 1 "id": 1
}, },
{ {
"seats": [ "seats": [
"H2", "H2",
"H3", "H1",
"H1" "H4"
], ],
"id": 2 "id": 2
}, },
...@@ -126,6 +130,12 @@ ...@@ -126,6 +130,12 @@
"G4" "G4"
], ],
"id": 3 "id": 3
},
{
"seats": [
"G8"
],
"id": 4
} }
] ]
} }
\ No newline at end of file
import "./App.css"; import "./App.css";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom"; import { Route, Routes } from "react-router-dom";
import { _Login } from "../src/pages/login"; import { LoginPage } from "../src/pages/login";
import { _Seatlayout } from "../src/pages/seat-layout"; import { SeatLayoutPage } from "../src/pages/seat-layout";
import { _Confirmation } from "../src/pages/confirmation"; import { ConfirmationPage } from "../src/pages/confirmation";
import { _seatLimit } from "../src/pages/seat-limit"; import { SeatLimitPage } from "../src/pages/seat-limit";
import { useEffect } from "react";
import { useNavigate } from "react-router-dom";
function App() { function App() {
const navigate = useNavigate();
useEffect(() => {
const userIsLoggedIn = sessionStorage.getItem("userId");
userIsLoggedIn ?? navigate("/");
// Navigate to the booking if the user is logged in
}, [navigate]);
return ( return (
<div className="App"> <div className="App">
<Router>
<Routes> <Routes>
<Route path="/" element={<_Login />} /> <Route path="/" element={<LoginPage />} />
<Route path="/seat-limit" element={<_seatLimit />} /> <Route path="/seat-limit" element={<SeatLimitPage />} />
<Route path="/booking" element={<_Seatlayout />} /> <Route path="/booking" element={<SeatLayoutPage />} />
<Route path="/confirmation" element={<_Confirmation />} /> <Route path="/confirmation" element={<ConfirmationPage />} />
{/* Default route */} {/* Default route */}
<Route path="*" element={<_Login />} /> <Route path="*" element={<LoginPage />} />
</Routes> </Routes>
</Router>
</div> </div>
); );
} }
......
...@@ -4,7 +4,7 @@ import style from "./confirmation.module.css"; ...@@ -4,7 +4,7 @@ import style from "./confirmation.module.css";
import Button from "../../base/button"; import Button from "../../base/button";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
function Confirmation({ seatCount, seats, onLogOut, onEdit }) { function Confirmation({ seatCount = 0, seats = 0, onLogOut, onEdit }) {
return ( return (
<Layout title="Booking Confirmed"> <Layout title="Booking Confirmed">
<div className={style.confirmation}> <div className={style.confirmation}>
......
import { useState } from "react"; import { useState } from "react";
import Button from "../../base/button"; import Button from "../../base/button";
import Input from "../../base/input"; import Input from "../../base/input";
import Layout from "../../base/layout"; import Layout from "../../base/layout";
...@@ -12,7 +11,6 @@ function Login({ onSubmit }) { ...@@ -12,7 +11,6 @@ function Login({ onSubmit }) {
e.preventDefault(); e.preventDefault();
if (mobile.length < 10) { if (mobile.length < 10) {
setIsError(true); setIsError(true);
toast.info("mobile should be 10 digits"); toast.info("mobile should be 10 digits");
} else { } else {
onSubmit({ mobile }); onSubmit({ mobile });
...@@ -26,9 +24,8 @@ function Login({ onSubmit }) { ...@@ -26,9 +24,8 @@ function Login({ onSubmit }) {
return ( return (
<Layout title="Login"> <Layout title="Login">
<form className="form" onSubmit={handleSubmit}> <form className={styles.form} onSubmit={handleSubmit}>
<div> <label className={styles.label}>Mobile:</label>
<label className="label">Mobile:</label>
<Input <Input
placeholder="Enter Mobile" placeholder="Enter Mobile"
type="tel" type="tel"
...@@ -36,11 +33,10 @@ function Login({ onSubmit }) { ...@@ -36,11 +33,10 @@ function Login({ onSubmit }) {
maxLength={10} maxLength={10}
onChange={handleChange} onChange={handleChange}
/> />
{iserror && ( {iserror && <span className={styles.span}>Please enter 10 digits</span>}
<span className={styles.span}>Please enter 10 digits</span> <div className={styles.button}>
)}
</div>
<Button>Submit</Button> <Button>Submit</Button>
</div>
</form> </form>
</Layout> </Layout>
); );
......
.span { .span {
color: red; color: red;
} }
.form {
margin-inline: 1rem;
}
.button {
margin-top: 1rem;
}
.label {
color: #6c6a6a;
font-weight: 500;
}
...@@ -14,6 +14,11 @@ function SeatLayout({ ...@@ -14,6 +14,11 @@ function SeatLayout({
isLoading, isLoading,
}) { }) {
const [selectedseat, setSelectedSeat] = useState([...selectedSeats]); const [selectedseat, setSelectedSeat] = useState([...selectedSeats]);
useEffect(() => {
setSelectedSeat([...selectedSeats]);
}, [selectedSeats]);
const handleSeats = (seat) => { const handleSeats = (seat) => {
if (!selectedseat?.includes(seat) && selectedseat.length < seatLimit) { if (!selectedseat?.includes(seat) && selectedseat.length < seatLimit) {
setSelectedSeat([...selectedseat, seat]); setSelectedSeat([...selectedseat, seat]);
...@@ -23,9 +28,7 @@ function SeatLayout({ ...@@ -23,9 +28,7 @@ function SeatLayout({
toast.info(`Cannot select seat more than ${seatLimit}`); toast.info(`Cannot select seat more than ${seatLimit}`);
} }
}; };
useEffect(() => {
setSelectedSeat([...selectedSeats]);
}, [selectedSeats]);
const handleConfirm = (e) => { const handleConfirm = (e) => {
e.preventDefault(); e.preventDefault();
if (!selectedseat.length || selectedseat.length < seatLimit) { if (!selectedseat.length || selectedseat.length < seatLimit) {
......
...@@ -3,6 +3,7 @@ import Button from "../../base/button"; ...@@ -3,6 +3,7 @@ import Button from "../../base/button";
import Layout from "../../base/layout"; import Layout from "../../base/layout";
import Input from "../../base/input"; import Input from "../../base/input";
import { toast } from "react-toastify"; import { toast } from "react-toastify";
import styles from "./seat-limit.module.css";
function SeatLimit({ onLimit, ...props }) { function SeatLimit({ onLimit, ...props }) {
const [limit, setLimit] = useState(0); const [limit, setLimit] = useState(0);
const handleLimit = (e) => { const handleLimit = (e) => {
...@@ -15,8 +16,7 @@ function SeatLimit({ onLimit, ...props }) { ...@@ -15,8 +16,7 @@ function SeatLimit({ onLimit, ...props }) {
}; };
return ( return (
<Layout title="How many seats?"> <Layout title="How many seats?">
<form onSubmit={handleLimit} className="form"> <form onSubmit={handleLimit} className={styles.form}>
<div>
<label className="label">No of seats:</label> <label className="label">No of seats:</label>
<Input <Input
type="number" type="number"
...@@ -25,8 +25,9 @@ function SeatLimit({ onLimit, ...props }) { ...@@ -25,8 +25,9 @@ function SeatLimit({ onLimit, ...props }) {
min="1" min="1"
max="10" max="10"
/> />
</div> <div className={styles.button}>
<Button {...props}>Book Seats</Button> <Button {...props}>Book Seats</Button>
</div>
</form> </form>
</Layout> </Layout>
); );
......
/* .label { .form {
color: #6c6a6a; margin-inline: 1rem;
} }
.button {
.form > *:not(input) { margin-top: 1rem;
padding: 17px;
} }
.label {
input[type="number"]::-webkit-inner-spin-button { color: #6c6a6a;
display: none; font-weight: 500;
} }
input[type="number"] {
-moz-appearence: textfield;
} */
...@@ -11,20 +11,22 @@ input[type="checkbox"] { ...@@ -11,20 +11,22 @@ input[type="checkbox"] {
border: 1px solid #ccc; border: 1px solid #ccc;
box-shadow: none; box-shadow: none;
padding: 0.7rem; padding: 0.7rem;
cursor: pointer;
} }
.checkbox-reserved { .checkbox-reserved {
background: #848489; background: #848489;
border: none !important; border: none !important;
cursor: not-allowed;
} }
.checkbox-selected { .checkbox-selected {
background: #01fff7; background: #01fff7;
border: none !important; border: none !important;
cursor: pointer;
} }
.checkbox-available { .checkbox-available {
padding: 0.6rem !important; padding: 0.6rem !important;
cursor: pointer;
} }
.tooltip { .tooltip {
......
...@@ -5,61 +5,86 @@ export const AppContext = createContext(); ...@@ -5,61 +5,86 @@ export const AppContext = createContext();
export const useAppContext = () => useContext(AppContext); export const useAppContext = () => useContext(AppContext);
export function ContextProvider({ children }) { export function ContextProvider({ children }) {
const [userseats, setUserSeats] = useState([]); const [userSeats, setUserSeats] = useState([]);
const [seats, setSeats] = useState([]); const [reservedSeats, setReservedSeats] = useState([]);
const [seatLayout, setSeatLayout] = useState([]);
const [isLoading, setisLoading] = useState(false); const [isLoading, setisLoading] = useState(false);
const LoginOrRegister = async ({ mobile }) => {
const loginOrRegister = async ({ mobile }) => {
try { try {
const user = await api.GetUserByMobile({ mobile }); const user = await api.getUserByMobile({ mobile });
if (!user.length) { if (!user.length) {
//register //register
const response = await api.Register({ mobile }); const response = await api.register({ mobile });
return await response; sessionStorage.setItem("userId", response?.id);
await getAllReservedSeats();
// return true for newly registered user
return true;
} else { } else {
//login //login
return await user[0]; sessionStorage.setItem("userId", user?.[0]?.id);
const response = await getAllReservedSeats();
const userSelectedSeats = response.filter((e) => e.id == user[0]?.id);
sessionStorage.setItem(
"seatLimit",
userSelectedSeats?.[0]?.seats?.length
);
// return false for already registered user
return false;
} }
} catch (err) { } catch (err) {
toast.error(err.message); toast.error(err.message);
} }
}; };
const AddOrUpdateSeats = async ({ id, seats }) => { const addOrUpdateSeats = async ({ id, seats }) => {
try { try {
const isSeats = userseats.filter((e) => e.id == id); //check user already booked seats or not
//check the id if (!userSeats.length) {
if (!isSeats.length) { //add seats into reserved seats
//add seats const response = await api.addSeats({ seats });
const response = await api.AddSeats({ seats }); setReservedSeats([...reservedSeats, response]);
setUserSeats([...userseats, response]);
} else { } else {
//update seats //update user seats only
const response = await api.UpdateSeats({ id, seats }); const response = await api.updateSeats({ id, seats });
const result = userseats.map((e) => (e[id] == id ? response : e)); setUserSeats(response.seats);
setUserSeats(result);
} }
} catch (err) { } catch (err) {
toast.error(err.message); toast.error(err.message);
} }
}; };
const GetAllSeats = async () => { const getAllReservedSeats = async () => {
setisLoading(false); setisLoading(false);
try { try {
//to clear the data for glitch //to clear the data for glitch
setReservedSeats([]);
setUserSeats([]); setUserSeats([]);
const response = await api.GetAllSeats(); const response = await api.getAllReservedSeats();
setUserSeats(response); const userid = sessionStorage.getItem("userId");
response.map((e) =>
e.id != userid
? // condition1=get all reserved seats except logged user
setReservedSeats((prevReservedSeat) => [
...prevReservedSeat,
...e.seats,
])
: // condition2=get only reserved seats of logged user
setUserSeats(e.seats)
);
setisLoading(true); setisLoading(true);
return await response;
} catch (err) { } catch (err) {
toast.error(err.message); toast.error(err.message);
} }
}; };
const GetSeats = async () => { const getSeatLayout = async () => {
setisLoading(false); setisLoading(false);
try { try {
setSeats([]); setSeatLayout([]);
const response = await api.GetSeats(); const response = await api.getSeatLayout();
setSeats(response); setSeatLayout(response);
setisLoading(true); setisLoading(true);
} catch (err) { } catch (err) {
toast.error(err.message); toast.error(err.message);
...@@ -67,13 +92,14 @@ export function ContextProvider({ children }) { ...@@ -67,13 +92,14 @@ export function ContextProvider({ children }) {
}; };
const value = { const value = {
userseats, userSeats,
reservedSeats,
isLoading, isLoading,
seats, seatLayout,
LoginOrRegister, loginOrRegister,
AddOrUpdateSeats, addOrUpdateSeats,
GetAllSeats, getAllReservedSeats,
GetSeats, getSeatLayout,
}; };
return <AppContext.Provider value={value}>{children}</AppContext.Provider>; return <AppContext.Provider value={value}>{children}</AppContext.Provider>;
} }
...@@ -18,13 +18,6 @@ code { ...@@ -18,13 +18,6 @@ code {
monospace; monospace;
} }
.label {
color: #6c6a6a;
}
.form > *:not(input) {
padding: 17px;
}
input[type="number"]::-webkit-inner-spin-button { input[type="number"]::-webkit-inner-spin-button {
display: none; display: none;
} }
......
...@@ -3,11 +3,13 @@ import ReactDOM from "react-dom/client"; ...@@ -3,11 +3,13 @@ import ReactDOM from "react-dom/client";
import "./index.css"; import "./index.css";
import App from "./App"; import App from "./App";
import reportWebVitals from "./reportWebVitals"; import reportWebVitals from "./reportWebVitals";
import { ContextProvider } from "./_context"; import { ContextProvider } from "./context";
import { ToastContainer } from "react-toastify"; import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css"; import "react-toastify/dist/ReactToastify.css";
import { BrowserRouter as Router } from "react-router-dom";
const root = ReactDOM.createRoot(document.getElementById("root")); const root = ReactDOM.createRoot(document.getElementById("root"));
root.render( root.render(
<Router>
<ContextProvider> <ContextProvider>
<App /> <App />
...@@ -24,6 +26,7 @@ root.render( ...@@ -24,6 +26,7 @@ root.render(
theme="colored" theme="colored"
/> />
</ContextProvider> </ContextProvider>
</Router>
); );
// If you want to start measuring performance in your app, pass a function // If you want to start measuring performance in your app, pass a function
......
const BASE_URL = process.env.REACT_APP_BASE_URL; const BASE_URL = process.env.REACT_APP_BASE_URL;
export async function Login({ mobile }) { export async function login({ mobile }) {
// Attempt to fetch user data // Attempt to fetch user data
const response = await fetch(`${BASE_URL}/users?mobile=${mobile}`); const response = await fetch(`${BASE_URL}/users?mobile=${mobile}`);
const result = await response.json(); const result = await response.json();
return result; return result;
} }
export async function Register({ mobile }) { export async function register({ mobile }) {
// User not found, register // User not found, register
const user = await fetch(`${BASE_URL}/users`, { const user = await fetch(`${BASE_URL}/users`, {
method: "POST", method: "POST",
...@@ -18,8 +18,9 @@ export async function Register({ mobile }) { ...@@ -18,8 +18,9 @@ export async function Register({ mobile }) {
return await user.json(); return await user.json();
} }
export async function AddSeats({ id, seats }) { export async function addSeats({ id, seats }) {
//add seat //add seat
//here id = userid
const response = await fetch(`${BASE_URL}/reservedSeats `, { const response = await fetch(`${BASE_URL}/reservedSeats `, {
method: "POST", method: "POST",
headers: { "Content-Type": "application/json" }, headers: { "Content-Type": "application/json" },
...@@ -28,7 +29,7 @@ export async function AddSeats({ id, seats }) { ...@@ -28,7 +29,7 @@ export async function AddSeats({ id, seats }) {
return await response.json(); return await response.json();
} }
export async function UpdateSeats({ id, seats }) { export async function updateSeats({ id, seats }) {
//update //update
const response = await fetch(`${BASE_URL}/reservedSeats/${id}`, { const response = await fetch(`${BASE_URL}/reservedSeats/${id}`, {
method: "PUT", method: "PUT",
...@@ -38,21 +39,17 @@ export async function UpdateSeats({ id, seats }) { ...@@ -38,21 +39,17 @@ export async function UpdateSeats({ id, seats }) {
return await response.json(); return await response.json();
} }
export async function GetAllSeats() { export async function getAllReservedSeats() {
const response = await fetch(`${BASE_URL}/reservedSeats`); const response = await fetch(`${BASE_URL}/reservedSeats`);
return await response.json(); return await response.json();
} }
export async function GetSeats() { export async function getSeatLayout() {
const response = await fetch(`${BASE_URL}/bookingSeats`); const response = await fetch(`${BASE_URL}/seatLayout`);
return await response.json(); return await response.json();
} }
export async function GetUserByMobile({ mobile }) { export async function getUserByMobile({ mobile }) {
const response = await fetch(`${BASE_URL}/users?mobile=${mobile}`); const response = await fetch(`${BASE_URL}/users?mobile=${mobile}`);
return await response.json(); return await response.json();
} }
export async function GetSeatById(id) {
const response = await fetch(`${BASE_URL}/reservedSeats/${id}`);
return await response.json();
}
import Confirmation from "../components/top-level/confirmation"; import Confirmation from "../components/top-level/confirmation";
import { useLocation, useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
import { useEffect, useState } from "react"; import { useAppContext } from "../context";
import { useAppContext } from "../_context"; import { useLocation } from "react-router-dom";
export function _Confirmation() { export function ConfirmationPage() {
const [count, setCount] = useState(0); let { getAllReservedSeats } = useAppContext();
const [reservedseat, setReservedSeat] = useState([]);
let { GetSeatById } = useAppContext();
const navigate = useNavigate(); const navigate = useNavigate();
const location = useLocation(); const location = useLocation();
useEffect(() => { const handleModify = async (e) => {
getSeatById();
}, []);
const getSeatById = async () => {
if (location?.state?.seats.length) {
setCount(location.state.seats.length);
setReservedSeat(location.state.seats);
} else {
const userid = sessionStorage.getItem("userId");
const userseats = await GetSeatById(userid);
setCount(userseats.seats.length);
setReservedSeat(userseats.seats);
}
};
const handleModify = (e) => {
e.preventDefault(); e.preventDefault();
await getAllReservedSeats();
navigate("/booking"); navigate("/booking");
}; };
return ( return (
<Confirmation <Confirmation
seatCount={count} seatCount={location?.state?.seats?.length}
seats={reservedseat} seats={location?.state?.seats}
onEdit={handleModify} onEdit={handleModify}
/> />
); );
......
import { useEffect, useState } from "react"; import { useEffect } from "react";
import { useAppContext } from "../_context"; import { useAppContext } from "../context";
import Login from "../components/top-level/login"; import Login from "../components/top-level/login";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
export function _Login() { export function LoginPage() {
const navigate = useNavigate(); const navigate = useNavigate();
const { userseats, LoginOrRegister, GetAllSeats } = useAppContext(); const { loginOrRegister } = useAppContext();
const [isLogged, setIsLogged] = useState(false);
useEffect(() => { useEffect(() => {
sessionStorage.clear(); sessionStorage.clear();
}, []); }, []);
useEffect(() => {
isLogged && handleSeats();
}, [isLogged]);
const handleLogin = async ({ mobile }) => { const handleLogin = async ({ mobile }) => {
//get all seats and then login const isRegistered = await loginOrRegister({ mobile });
const users = await LoginOrRegister({ mobile }); if (isRegistered) {
sessionStorage.setItem("userId", users?.id);
await GetAllSeats();
setIsLogged(true);
};
const handleSeats = async () => {
const id = sessionStorage.getItem("userId");
const userReservedSeats = userseats.filter((e) => e.id == id);
if (!userReservedSeats.length) {
navigate("/seat-limit"); navigate("/seat-limit");
} else { } else {
sessionStorage.setItem("seatLimit", userReservedSeats[0].seats.length); navigate("/booking");
navigate("/booking", { state: { seats: userseats } });
} }
}; };
return <Login onSubmit={handleLogin} />; return <Login onSubmit={handleLogin} />;
} }
import { useEffect, useState } from "react"; import { useEffect } from "react";
import SeatLayout from "../components/top-level/seat-layout"; import SeatLayout from "../components/top-level/seat-layout";
import { useAppContext } from "../_context"; import { useAppContext } from "../context";
import { useLocation, useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
export function _Seatlayout() { export function SeatLayoutPage() {
let { userseats, isLoading, seats, AddOrUpdateSeats, GetAllSeats, GetSeats } = let {
useAppContext(); userSeats,
reservedSeats,
isLoading,
seatLayout,
addOrUpdateSeats,
getAllReservedSeats,
getSeatLayout,
} = useAppContext();
const [reservedSeat, setReservedSeat] = useState([]);
const [selectedSeat, setSelectedSeat] = useState([]);
const navigate = useNavigate(); const navigate = useNavigate();
const userId = sessionStorage.getItem("userId"); const userId = sessionStorage.getItem("userId");
const seatLimit = sessionStorage.getItem("seatLimit"); const seatLimit = sessionStorage.getItem("seatLimit");
const location = useLocation();
useEffect(() => {
GetSeats();
if (!location?.state?.seats.length) {
GetAllSeats();
}
const handleBeforeUnload = (event) => {
// Check if the page is about to unload or refresh
if (event.type === "beforeunload") {
navigate("/booking", { replace: true });
}
};
window.addEventListener("beforeunload", handleBeforeUnload);
return () => {
window.removeEventListener("beforeunload", handleBeforeUnload);
};
}, []);
// useEffect(() => {
// GetSeats();
// const handleBeforeUnload = (event) => {
// // Check if the page is about to unload or refresh
// if (event.type === "beforeunload") {
// sessionStorage.setItem("pageload", true);
// }
// };
// window.addEventListener("beforeunload", handleBeforeUnload);
// return () => {
// window.removeEventListener("beforeunload", handleBeforeUnload);
// };
// }, []);
// useEffect(() => {
// const reloadPage = sessionStorage.getItem("pageload");
// reloadPage && GetAllSeats();
// }, []);
useEffect(() => { useEffect(() => {
handleReservedSeats(); //it will check only on page refresh ,at the time of page refresh it will be empty
}, [userseats]); !reservedSeats.length && getAllReservedSeats();
getSeatLayout();
const handleReservedSeats = async () => { }, []);
let seatArray = [];
const selectedSeats = await userseats?.find((e) => e.id == userId);
const results = selectedSeats?.seats;
setSelectedSeat(results);
const reservedSeats = userseats?.filter((e) => e.id != userId);
reservedSeats?.forEach((element) => {
element?.seats.forEach((e) => {
seatArray = [...seatArray, e];
setReservedSeat(seatArray);
});
});
};
const handleConfirmed = async ({ id, seats }) => { const handleConfirmed = async ({ id, seats }) => {
await AddOrUpdateSeats({ id, seats }); await addOrUpdateSeats({ id, seats });
navigate("/confirmation", { state: { seats: seats } }); navigate("/confirmation", { state: { seats: seats } });
}; };
...@@ -75,9 +34,9 @@ export function _Seatlayout() { ...@@ -75,9 +34,9 @@ export function _Seatlayout() {
isLoading={isLoading} isLoading={isLoading}
userId={userId} userId={userId}
seatLimit={seatLimit} seatLimit={seatLimit}
seats={seats} seats={seatLayout}
selectedSeats={selectedSeat} selectedSeats={userSeats}
reservedSeats={reservedSeat} reservedSeats={reservedSeats}
onClick={handleConfirmed} onClick={handleConfirmed}
/> />
); );
......
import SeatLimit from "../components/top-level/seat-limit"; import SeatLimit from "../components/top-level/seat-limit";
import { useNavigate } from "react-router-dom"; import { useNavigate } from "react-router-dom";
export function _seatLimit() { export function SeatLimitPage() {
const navigate = useNavigate(); const navigate = useNavigate();
const handleLimit = (e) => { const handleLimit = (e) => {
sessionStorage.setItem("seatLimit", e.limit); sessionStorage.setItem("seatLimit", e.limit);
//for Auth Guard
sessionStorage.setItem("currentPath", "/booking");
navigate("/booking"); navigate("/booking");
}; };
return <SeatLimit onLimit={handleLimit} />; return <SeatLimit onLimit={handleLimit} />;
......
export const bookingSeats = [
[0, "A1", "A2", "A3", 0, "A4", "A5", "A6", 0],
["B1", "B2", "B3", "B4", 0, "B5", "B6", "B7", "B8"],
["C1", "C2", "C3", "C4", 0, "C5", "C6", "C7", "C8"],
["D1", "D2", "D3", "D4", 0, "D5", "D6", "D7", "D8"],
["E1", "E2", "E3", "E4", 0, "E5", "E6", "E7", "E8"],
["F1", "F2", "F3", "F4", 0, "F5", "F6", "F7", "F8"],
["G1", "G2", "G3", "G4", 0, "G5", "G6", "G7", "G8"],
[0, "H1", "H2", "H3", 0, "H4", "H5", "H7", 0],
];
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment