Commit 912f0c05 by Manivasagam S

code changes

parent dd99cbe1
// Notification.jsx
import PropTypes from "prop-types"; import PropTypes from "prop-types";
import styles from "../Notification/Notification.module.css"; import styles from "../Notification/Notification.module.css";
import successImg from "../../../assets/success.png"; import successImg from "../../../assets/success.png";
import errorImg from "../../../assets/giferror.gif"; import errorImg from "../../../assets/giferror.gif";
import cn from "classnames"; import cn from "classnames";
export const Notification = ({ title, type, msg, button, }) => { export const Notification = ({ title, type, msg, button, seats }) => {
const selectedImage = type === "success" ? successImg : errorImg; const selectedImage = type === "success" ? successImg : errorImg;
return ( return (
<>
{/* <div className={styles.logoutButton}>
<AiOutlineLogout onClick={onLogout}/>
</div> */}
<div className={styles.container}> <div className={styles.container}>
<span className={styles.span}> <span className={styles.span}>
<img <img
src={selectedImage} src={selectedImage}
...@@ -23,11 +20,25 @@ export const Notification = ({ title, type, msg, button, }) => { ...@@ -23,11 +20,25 @@ export const Notification = ({ title, type, msg, button, }) => {
})} })}
/> />
</span> </span>
<h2 className={styles.title}>{title}</h2> <h2 className={styles.title}>{title}</h2>
<p className={styles.msg}>{msg}</p> <p className={styles.msg}>{msg}</p>
<div className={styles.button}> {button && button}</div>
{seats && seats.length > 0 && (
<div className={styles.seatListWrapper}>
<h4 className={styles.seatTitle}>🎫 Your Seats:</h4>
<ul className={styles.seatList}>
{seats.map((seat, index) => (
<li key={index} className={styles.seatItem}>
{seat}
</li>
))}
</ul>
</div>
)}
<div className={styles.button}>{button}</div>
</div> </div>
</>
); );
}; };
...@@ -36,4 +47,5 @@ Notification.propTypes = { ...@@ -36,4 +47,5 @@ Notification.propTypes = {
title: PropTypes.string.isRequired, title: PropTypes.string.isRequired,
msg: PropTypes.string.isRequired, msg: PropTypes.string.isRequired,
button: PropTypes.element, button: PropTypes.element,
seats: PropTypes.arrayOf(PropTypes.string),
}; };
...@@ -13,81 +13,75 @@ ...@@ -13,81 +13,75 @@
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: 20rem; margin: 5rem auto;
text-align: center; text-align: center;
transition: transform 0.3s ease-in-out, opacity 0.3s ease-in-out;
animation: fadeIn 0.5s ease-in-out;
width: 100%; width: 100%;
max-width: 25rem; max-width: 25rem;
background-color: #eff0ef;
padding: 3rem; padding: 3rem;
background-color: #eff0ef;
border-radius: 2rem; border-radius: 2rem;
margin: 10rem auto; animation: fadeIn 0.5s ease-in-out;
} }
/* .container:hover {
transform: scale(1.02);
opacity: 0.95;
} */
.span { .span {
font-size: 4rem; font-size: 4rem;
margin-bottom: 0.5rem; margin-bottom: 0.5rem;
} }
.title,
.msg {
color: #100f0f;
font-family: 'Segoe UI', sans-serif;
font-weight: bold;
}
.title { .title {
margin-bottom: 0.5em;
font-size: 1.5rem; font-size: 1.5rem;
color: rgb(16, 15, 15); margin-bottom: 0.5em;
font-weight: bold;
font-family: 'Segoe UI';
} }
.msg { .msg {
font-size: 1.5rem; font-size: 1.5rem;
color: rgb(16, 15, 15); margin: 0.5rem 0 2rem;
margin-top: 0.5rem;
line-height: 1.5; line-height: 1.5;
font-family: 'Segoe UI';
font-weight: bold;
margin-bottom: 2rem;
} }
.success,
.error {
height: 9.375rem;
width: 9.375rem;
}
.success { .success {
color: #2ecc71;
width: 9.375rem;
height: auto;
animation: rotate 1s linear, glow 7s ease-in-out alternate; animation: rotate 1s linear, glow 7s ease-in-out alternate;
} }
.error { .error {
color: #e74c3c;
height:9.375rem;
width: 12.5rem; width: 12.5rem;
} }
.button { .button {
max-width: 12rem;
width: 100%; width: 100%;
max-width: 12rem;
text-align: center; text-align: center;
margin-top: 1rem;
} }
.button button { .button button {
width: 100%; width: 100%;
padding: 0.75rem 1.5rem; padding: 0.75rem 1.5rem;
background-color: var(--primary);
color: white;
font-size: 1.1rem; font-size: 1.1rem;
font-weight: bold;
color: white;
background-color: var(--primary);
border: none; border: none;
border-radius: 0.5rem; border-radius: 0.5rem;
font-weight: bold;
cursor: pointer; cursor: pointer;
transition: background-color 0.3s ease-in-out, transform 0.2s; transition: background-color 0.3s, transform 0.2s;
} }
.button button:hover { .button button:hover {
background-color:var(--primary); background-color: var(--primary);
transform: translateY(-2px); transform: translateY(-2px);
} }
...@@ -124,3 +118,36 @@ ...@@ -124,3 +118,36 @@
filter: drop-shadow(0 0 20px #c8d92f); filter: drop-shadow(0 0 20px #c8d92f);
} }
} }
.seatListWrapper {
margin-top: 1rem;
background-color: #f5f5f5;
padding: 1rem;
border-radius: 1rem;
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}
.seatTitle {
margin-bottom: 0.5rem;
font-weight: 600;
color: #333;
}
.seatList {
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 0.5rem;
list-style: none;
padding: 0;
margin: 0;
}
.seatItem {
background-color: #d1e7dd;
color: #0f5132;
padding: 0.4rem 0.8rem;
border-radius: 0.5rem;
font-size: 1rem;
font-weight: 500;
}
...@@ -4,20 +4,24 @@ import { Notification } from "../../Notification/Notification"; ...@@ -4,20 +4,24 @@ import { Notification } from "../../Notification/Notification";
import { Button } from "../../../Base/Buttons/Button"; import { Button } from "../../../Base/Buttons/Button";
export const Success = () => { export const Success = () => {
const [showConfetti, setShowConfetti] = useState(true);
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });
const [bookedSeats, setBookedSeats] = useState([]);
const response = { const response = {
title: 'Success🎉', title: 'Success 🎉',
type: 'success', type: 'success',
msg: 'Successfully booked your ticket!', msg: 'Successfully booked your ticket!',
}; };
const [showConfetti, setShowConfetti] = useState(true);
const [windowSize, setWindowSize] = useState({ width: 0, height: 0 });
useEffect(() => { useEffect(() => {
setWindowSize({ width: window.innerWidth, height: window.innerHeight }); setWindowSize({ width: window.innerWidth, height: window.innerHeight });
const seats = JSON.parse(localStorage.getItem("bookedSeats")) || [];
setBookedSeats(seats);
// Confetti timeout
const timer = setTimeout(() => { const timer = setTimeout(() => {
setShowConfetti(false); setShowConfetti(false);
}, 20000); }, 10000);
return () => clearTimeout(timer); return () => clearTimeout(timer);
}, []); }, []);
...@@ -32,16 +36,18 @@ export const Success = () => { ...@@ -32,16 +36,18 @@ export const Success = () => {
<Confetti width={windowSize.width} height={windowSize.height} /> <Confetti width={windowSize.width} height={windowSize.height} />
)} )}
<Notification {...response} button={<Button variant="secondary" <Notification
{...response}
seats={bookedSeats}
button={
<Button
variant="secondary"
label="Book more seats" label="Book more seats"
size="md" onClick={handleSuccess}/>}/> size="md"
<div
style={{ display: "flex", justifyContent: "center", marginTop: "1rem" }}
onClick={handleSuccess} onClick={handleSuccess}
> />
}
</div> />
</> </>
); );
}; };
...@@ -97,6 +97,10 @@ export const Selectseat = ({ onLogout }) => { ...@@ -97,6 +97,10 @@ export const Selectseat = ({ onLogout }) => {
.then(res => { .then(res => {
if (res) { if (res) {
toast.success("Seats booked!"); toast.success("Seats booked!");
hasWelcomed.current=true;
const finalSeats = [...selectedData, ...selectedSeats];
localStorage.setItem("bookedSeats", JSON.stringify(selectedSeats));
console.log(selectedSeats);
setSelectedSeats([]); setSelectedSeats([]);
setTimeout(() => { setTimeout(() => {
window.location.replace("/success"); window.location.replace("/success");
......
...@@ -17,6 +17,7 @@ export const getCurrentUser = () => { ...@@ -17,6 +17,7 @@ export const getCurrentUser = () => {
export const logout = () => { export const logout = () => {
localStorage.removeItem("user"); localStorage.removeItem("user");
localStorage.removeItem("bookedSeats");
window.location.replace('/'); window.location.replace('/');
return; return;
}; };
...@@ -18,10 +18,7 @@ ...@@ -18,10 +18,7 @@
"phoneNumber": "9361775481", "phoneNumber": "9361775481",
"name": "mani", "name": "mani",
"reservedSeats": [ "reservedSeats": [
"A4", "E5"
"A5",
"A6",
"B7"
] ]
}, },
{ {
...@@ -45,7 +42,9 @@ ...@@ -45,7 +42,9 @@
"name": "mani", "name": "mani",
"email": "mani@gmail.com", "email": "mani@gmail.com",
"phoneNumber": "9312345678", "phoneNumber": "9312345678",
"reservedSeats": [] "reservedSeats": [
"B6"
]
}, },
{ {
"id": "845c", "id": "845c",
...@@ -66,7 +65,11 @@ ...@@ -66,7 +65,11 @@
"name": "ganesh", "name": "ganesh",
"email": "ganesh@gmail.com", "email": "ganesh@gmail.com",
"phoneNumber": "9786543219", "phoneNumber": "9786543219",
"reservedSeats": [] "reservedSeats": [
"C6",
"C7",
"B8"
]
}, },
{ {
"id": "9659", "id": "9659",
......
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