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

Redirect "/list" to "/" when there is no token #25

Merged
merged 3 commits into from
May 1, 2023

Conversation

emilysellers
Copy link
Collaborator

@emilysellers emilysellers commented Apr 27, 2023

Description

This PR fixes the user being able to view the List view if they don't yet have a token. Now, if the user doesn't have a token and clicks List in the nav bar or enters "/list" in the URL bar, the Home view persists. Once the user creates a new list or enters a token for an existing list, the token is stored in local storage and the user is then able to view the List view.

Something to consider: should the same check be implemented for the Add Item view so that if a user doesn't yet have a token, they are not able to navigate to the Add Item view?

Related Issue

Closes #24

Acceptance Criteria

  • If the user doesn't already have a token, clicking List in the nav bar or entering "/list" in the URL bar will keep the user on the home page.

Type of Changes

Type
🐛 Bug fix
✨ New feature
🔨 Refactoring
💯 Add tests
🔗 Update dependencies
📜 Docs

Updates

Before

In this before video, there is no token in local storage. The user clicks the List link in the nav bar and is redirected to the List view.

TCL.Issue.14.before.mov

After

In this after video, there is no token in local storage. The user clicks the List link in the nav bar and still sees the Home view, then enters "/list" in the URL bar and still sees the Home view. The user then clicks the Create new list button, the token is saved to local storage and the user is redirected to the List view.

TCL.Issue.14.after.mov

Testing Steps / QA Criteria

@emilysellers emilysellers self-assigned this Apr 27, 2023
@github-actions
Copy link

github-actions bot commented Apr 27, 2023

Visit the preview URL for this PR (updated for commit 1d0906b):

https://tcl-57-smart-shopping-list--pr25-es-no-token-redirect-k44q2dr8.web.app

(expires Mon, 08 May 2023 03:31:54 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: ad3eb6c34c2ec5986fcc218178df5985eb9c9ffb

@emilysellers emilysellers marked this pull request as ready for review April 27, 2023 18:13
@emilysellers emilysellers added the bug Something isn't working label Apr 27, 2023
Copy link
Collaborator

@djtaylor8 djtaylor8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this, @emilysellers!

Copy link
Collaborator

@Amy-Pr Amy-Pr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Emily! To answer your question, I would vote for doing the same with the Add Item view.

Copy link
Collaborator

@danainjax danainjax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good & thanks!

src/App.jsx Outdated
Comment on lines 69 to 72
<Route
path="/list"
element={listToken ? <List data={data} /> : <Navigate to="/" />}
/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a very useful line of code, @emilysellers. Thank you for doing this extra to make the app more usable. 😁👍🏻

@emilysellers emilysellers merged commit a2ca04c into main May 1, 2023
2 checks passed
@emilysellers emilysellers deleted the es-no-token-redirects-home branch May 1, 2023 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

14. As a user, I want "/list" to redirect to the home page if there is no token
4 participants