Commit e8d7fd51 by Madhankumar

confirmation page setup

parent 358dda61
...@@ -8,6 +8,15 @@ ...@@ -8,6 +8,15 @@
} }
], ],
"reservedSeats": [ "reservedSeats": [
{
"userId": 1,
"seats": [
"C2",
"C3",
"C4",
"C1"
],
"id": 1
}
] ]
} }
\ No newline at end of file
...@@ -15,6 +15,7 @@ function App() { ...@@ -15,6 +15,7 @@ function App() {
<Routes> <Routes>
<Route path="/" element={<_Login />} /> <Route path="/" element={<_Login />} />
<Route path="/booking/:id" element={<_Seatlayout />} /> <Route path="/booking/:id" element={<_Seatlayout />} />
<Route path="/confirmation" element={<_Confirmation />} />
</Routes> </Routes>
</div> </div>
); );
......
...@@ -23,6 +23,6 @@ ...@@ -23,6 +23,6 @@
padding: 0.3rem; padding: 0.3rem;
} }
h2 { h2.header2 {
text-align: center; text-align: center;
} }
.confirmation { .confirmation {
text-align: center; text-align: center;
padding: 2rem; padding: 2rem;
width: 20em;
} }
.confirmation img { .confirmation img {
......
...@@ -3,7 +3,7 @@ import Confirmation from "."; ...@@ -3,7 +3,7 @@ import Confirmation from ".";
export default { export default {
title: "Top-Level/Confirmation", title: "Top-Level/Confirmation",
component: Confirmation, component: Confirmation,
argTypes: {}, argTypes: { onClick: { action: "onClick" } },
}; };
export const confirmation = { export const confirmation = {
......
import Layout from "../../Base/layout"; import Layout from "../../Base/layout";
import Image from "../../../assets/conform.png"; import Image from "../../../assets/conform.png";
import style from "./confirmation.module.css"; import style from "./confirmation.module.css";
import Button from "../../Base/button";
import { useNavigate } from "react-router-dom";
function Confirmation({ seatCount, seats }) { function Confirmation({ id, seatCount, seats }) {
const navigate = useNavigate();
const handleModify = (e) => {
e.preventDefault();
navigate(`/booking/${id}`);
};
return ( return (
<Layout title="Booking Confirmed"> <Layout title="Booking Confirmed">
<div className={style.confirmation}> <div className={style.confirmation}>
...@@ -12,6 +19,7 @@ function Confirmation({ seatCount, seats }) { ...@@ -12,6 +19,7 @@ function Confirmation({ seatCount, seats }) {
Booked Seats: Booked Seats:
{seats.toString()} {seats.toString()}
</h4> </h4>
<Button onClick={handleModify}>Modify</Button>
</div> </div>
</Layout> </Layout>
); );
......
...@@ -3,8 +3,8 @@ import { useEffect, useState } from "react"; ...@@ -3,8 +3,8 @@ import { useEffect, useState } from "react";
import Button from "../../Base/button"; import Button from "../../Base/button";
import styles from "./seat-layout.module.css"; import styles from "./seat-layout.module.css";
import Seat from "../seat"; import Seat from "../seat";
import Confirmation from "../confirmation";
import { useNavigate } from "react-router-dom";
function SeatLayout({ function SeatLayout({
userId = 1, userId = 1,
seats, seats,
...@@ -13,6 +13,7 @@ function SeatLayout({ ...@@ -13,6 +13,7 @@ function SeatLayout({
onClick, onClick,
...props ...props
}) { }) {
const navigate = useNavigate();
const [selectedseat, setSelectedSeat] = useState([...selectedSeats]); const [selectedseat, setSelectedSeat] = useState([...selectedSeats]);
const [confirmation, setConfirmation] = useState(false); const [confirmation, setConfirmation] = useState(false);
const handleSeats = (seat) => { const handleSeats = (seat) => {
...@@ -30,14 +31,16 @@ function SeatLayout({ ...@@ -30,14 +31,16 @@ function SeatLayout({
//check if already have data then update otherwise create, //check if already have data then update otherwise create,
//write code //write code
onClick({ userId: parseInt(userId), seats: selectedseat }); onClick({ userId: parseInt(userId), seats: selectedseat });
const count = selectedseat?.length;
setTimeout(() => { setTimeout(() => {
setConfirmation(true); navigate("/confirmation", {
state: { seatCount: count, seats: selectedseat, id: userId },
});
}, 500); }, 500);
}; };
return ( return (
<> <>
{!confirmation ? (
<div className={styles.container}> <div className={styles.container}>
<h1>Choose Seats</h1> <h1>Choose Seats</h1>
<div className={styles.curve}> <div className={styles.curve}>
...@@ -83,9 +86,6 @@ function SeatLayout({ ...@@ -83,9 +86,6 @@ function SeatLayout({
</div> </div>
</div> </div>
</div> </div>
) : (
<Confirmation ticketCount={selectedseat.length} seats={selectedseat} />
)}
</> </>
); );
} }
......
import Confirmation from "../components/top-level/confirmation"; import Confirmation from "../components/top-level/confirmation";
import { useLocation } from "react-router-dom";
export function _Confirmation({ ...props }) { export function _Confirmation() {
return <Confirmation {...props} />; const location = useLocation();
const seatCount = location.state.seatCount;
const seats = location.state.seats;
const id = location.state.id;
return <Confirmation id={id} seatCount={seatCount} seats={seats} />;
} }
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