Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure site it stateless (1st solution in dev branch, 2nd solution can be used to modify code in main branch) #36

Open
mernaAlghannam opened this issue May 15, 2023 · 0 comments

Comments

@mernaAlghannam
Copy link
Contributor

mernaAlghannam commented May 15, 2023

Currently the main branch has an array that save all previous footsteps. Then, when you can the back button it decrements the array and updates all usestates as you can see in this function

const prevQuestion = useCallback(() => {

This is not ideal because if a the server crash, you will lose all content in array, and you will no longer be able to use the back button.

We propose two solutions:

1- use the dev branch because it uses dynamic routes. Therefore when it calls router.back. route.back in nextjs is like pressing the window back button on top. Navigate back in history. Equivalent to clicking the browser’s back button. It executes window.history.back() . Then, it would actually call this function again https://github.com/BU-Spark/se-bch-als-resource-app/blob/dev/code/src/pages/question/%5Bid%5D.tsx and make all the api calls again. Therefore, nothing is saved like in the main.

2- add a prev question and prev choices field in strapi. So, whenever you press back button, it calls prev question and choices and updates the pages. This way, you are not saving anything on site and site is stateless.

You can explore more options with your dev team to find best solutions. Good luck!

@mernaAlghannam mernaAlghannam changed the title Ensure site it stateless (1st solution in dev branch, 2nd solution is proposed by tech advisor and can be used to modify code in main branch) Ensure site it stateless (1st solution in dev branch, 2nd solution can be used to modify code in main branch) May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant