Skip to content

Commit

Permalink
implemented sessionStorage; ensuring that the popUpNotif shows once p…
Browse files Browse the repository at this point in the history
…er session :))
  • Loading branch information
riv-k committed Oct 15, 2024
1 parent eb37247 commit 362b66d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
3 changes: 2 additions & 1 deletion web/src/components/PopUpNotif.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default function PopUpNotif({ events }: PopUpNotifProps) {

const closePopup = () => {
setIsOpen(false);
sessionStorage.setItem("sameSession", "true"); //setting item in session storage, so that I can check for this in the passport page and display notification accordingly
};

return (
Expand Down Expand Up @@ -63,7 +64,7 @@ export default function PopUpNotif({ events }: PopUpNotifProps) {
{/* Event Name and Description */}
<div>
<p className="text-white text-center text-2xl">The next event:</p>
<p className="text-white text-center text-5xl font-semibold ">
<p className="text-white text-center text-4xl font-semibold ">
{nextEvent?.eventName || "Stay Tuned!"}
</p>
<p className="text-white text-center text-lg italic mt-3" style={{ color: "#FED066" }}>
Expand Down
20 changes: 13 additions & 7 deletions web/src/pages/Passport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ type PageComponent = React.ComponentType<any> | (() => ReactElement);

export default function Passport() {
const userData = GetLeaderboardStats();

// initialise index and loading state
const [currentIndex, setCurrentIndex] = useState(0);
const [events, setEvents] = useState([])
const [userStamps, setUserStamps] = useState<any[]>([])
const [loading, setLoading] = useState(true); // Add loading state

const [isPopUpVisible, setIsPopUpVisible] = useState(true);
const [isMobile, setIsMobile] = useState(true);


Expand Down Expand Up @@ -51,6 +51,12 @@ export default function Passport() {
};

fetchEvents();

//tracking session - showing popUpNotif once a session :)
if (sessionStorage.getItem("sameSession")) {
setIsPopUpVisible(false);
}

}, []);

//getting all stamps that user has collected
Expand Down Expand Up @@ -108,13 +114,13 @@ export default function Passport() {
if (loading) {
return (
<div
className="background flex flex-col h-screen justify-center items-center"
style={{ backgroundColor: "#e1ebff" }}
></div>
className="background flex flex-col h-screen justify-center items-center"
style={{ backgroundColor: "#e1ebff" }}
></div>
);
}

if(!isMobile) {
if (!isMobile) {
return <ErrorPage />;
}

Expand All @@ -141,7 +147,7 @@ export default function Passport() {
</div>
<div className="border-b-4 welcome-line w-88 mb-4 mt-1"></div>
</div>
<PopUpNotif events={events} />
{isPopUpVisible && <PopUpNotif events={events} />}
{typeof CurrentView === "function" ? <CurrentView /> : CurrentView}
<p>Page {currentIndex + 1}</p>
</div>
Expand Down

0 comments on commit 362b66d

Please sign in to comment.