ryanmio / DecodeMe-

DecodeMe! is a coding game with integrated language model.
https://decodeme.app/
MIT License
2 stars 0 forks source link

Implement navigation confirmation on game exit #70

Closed ryanmio closed 7 months ago

ryanmio commented 7 months ago

This commit introduces a feature that prompts the user for confirmation when they attempt to navigate away from an ongoing game session. The following changes have been made:

  1. Added a new state variable intendedRoute in index.js to store the destination route when a user tries to navigate away during a game.

  2. Modified the promptEndGame function in index.js to accept a route parameter and set the intendedRoute state, which triggers the display of the EndGameModal.

  3. Updated the confirmEndGame function in index.js to perform navigation to the intendedRoute after the game state has been reset and the modal is closed.

  4. Ensured that the cancelEndGame function in index.js clears the intendedRoute state and closes the modal without navigating away, allowing the user to continue the game.

  5. Passed the updated promptEndGame function as a prop to the OptionsMenu component and modified the navigation-related event handlers within OptionsMenu.js to call promptEndGame with the intended route.

  6. Ensured proper import and usage of the useRouter hook from next/router in both index.js and OptionsMenu.js for programmatic navigation.

These changes enhance the user experience by preventing accidental loss of game progress and providing a clear and user-friendly way to confirm navigation actions during gameplay.

netlify[bot] commented 7 months ago

Deploy Preview for decode-me ready!

Name Link
Latest commit d2f622d7743c7612638c79b3f661d2294b9ea3e3
Latest deploy log https://app.netlify.com/sites/decode-me/deploys/65b7ab121f38ee00089e9450
Deploy Preview https://deploy-preview-70--decode-me.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.