mirror of
https://github.com/mudabbir-ahmad/peworkshop.git
synced 2026-10-07 19:50:20 +00:00
changed the way clue buttons are rendered so their indexing exists for when they are needed but if the clue for them doesnt exist they dont cause errors
This commit is contained in:
1 parent
0d57df2559
commit
f7a5d744b0
2 files changed
+29
-60
No files matched your search
+28
-59
@@ -337,6 +337,24 @@ export default function MapPage() {
|
|||||||
// Get the first clue if it exists
|
// Get the first clue if it exists
|
||||||
const firstClue = clues.length > 0 ? clues[0] : null;
|
const firstClue = clues.length > 0 ? clues[0] : null;
|
||||||
|
|
||||||
|
// Render a clue button only if the clue exists
|
||||||
|
const renderClueButton = (index, position) => {
|
||||||
|
if (index >= clues.length) return null; // Don't render if clue doesn't exist
|
||||||
|
|
||||||
|
const clue = clues[index];
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
key={clue.id}
|
||||||
|
className={getClueButtonClass(clue)}
|
||||||
|
onClick={() => handleClueClick(clue.id, clue.available, clue.found)}
|
||||||
|
style={{
|
||||||
|
left: position.left,
|
||||||
|
top: position.top,
|
||||||
|
}}
|
||||||
|
></button>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["map-page"]}>
|
<div className={styles["map-page"]}>
|
||||||
{/* Map Banner with team info and timer */}
|
{/* Map Banner with team info and timer */}
|
||||||
@@ -363,66 +381,17 @@ export default function MapPage() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<div id="map-overlay-container" className={styles["map-overlay"]}>
|
<div id="map-overlay-container" className={styles["map-overlay"]}>
|
||||||
{/* Hardcoded Clue 1 button */}
|
{/* Render clue buttons conditionally */}
|
||||||
{firstClue && (
|
{renderClueButton(0, { left: "230px", top: "212px" })}
|
||||||
<button
|
{renderClueButton(1, { left: "320px", top: "285px" })}
|
||||||
className={getClueButtonClass(firstClue)}
|
{renderClueButton(2, { left: "265px", top: "400px" })}
|
||||||
onClick={() =>
|
{renderClueButton(3, { left: "343px", top: "520px" })}
|
||||||
handleClueClick(
|
{renderClueButton(4, { left: "320px", top: "646px" })}
|
||||||
firstClue.id,
|
{renderClueButton(5, { left: "298px", top: "774px" })}
|
||||||
firstClue.available,
|
{renderClueButton(6, { left: "240px", top: "880px" })}
|
||||||
firstClue.found
|
{renderClueButton(7, { left: "355px", top: "960px" })}
|
||||||
)
|
|
||||||
}
|
|
||||||
style={{
|
|
||||||
left: "230px",
|
|
||||||
top: "212px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Clue {firstClue.id} */}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{clues.length > 1 && (
|
{/* Additional clue buttons can be added here when needed */}
|
||||||
<button
|
|
||||||
className={getClueButtonClass(clues[1])}
|
|
||||||
onClick={() =>
|
|
||||||
handleClueClick(
|
|
||||||
clues[1].id,
|
|
||||||
clues[1].available,
|
|
||||||
clues[1].found
|
|
||||||
)
|
|
||||||
}
|
|
||||||
style={{
|
|
||||||
left: "320px",
|
|
||||||
top: "285px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Clue {clues[1].id} */}
|
|
||||||
{/* If clues are to be named uncomment the line above */}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{clues.length > 1 && (
|
|
||||||
<button
|
|
||||||
className={getClueButtonClass(clues[2])}
|
|
||||||
onClick={() =>
|
|
||||||
handleClueClick(
|
|
||||||
clues[2].id,
|
|
||||||
clues[2].available,
|
|
||||||
clues[2].found
|
|
||||||
)
|
|
||||||
}
|
|
||||||
style={{
|
|
||||||
left: "265px",
|
|
||||||
top: "400px",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{/* Clue {clues[2].id} */}
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{/* clues should go above here */}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ const JWT_SECRET =
|
|||||||
export function createToken(payload) {
|
export function createToken(payload) {
|
||||||
// Check if payload already has an expiration date set
|
// Check if payload already has an expiration date set
|
||||||
const options = payload.exp ? {} : { expiresIn: "30d" };
|
const options = payload.exp ? {} : { expiresIn: "30d" };
|
||||||
|
|
||||||
return jwt.sign(payload, JWT_SECRET, options);
|
return jwt.sign(payload, JWT_SECRET, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user