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

Issue #4 Solution #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Issue #4 Solution #4

wants to merge 2 commits into from

Conversation

zacharynoel
Copy link
Owner

Changes

List Changes Introduced by this PR

  1. This change to 'authReducer' sets the email that gets stored in state from action.payload.login to action.payload.email.

Purpose

Describe the problem or feature in addition to a link to the issues.

Approach

How does this change address the problem?

When submitting an order, the 'order_by' property is being set to auth.email (if it exists). When a user logs in, their email and token is dispatched and stored in state with a type and a payload (type being 'login' and the payload being an object that contains properties for email and token). However, when authReducer runs to store that payload into state, it sets the email property in state to action.payload.login. The issue here is that login does not exist in the payload, it should be email.

Pre-Testing TODOs

What needs to be done before testing

  • Login via the login page before submitting an order. This is necessary for your email to be stored in state.

Testing Steps

How do the users test this change?

  1. Login via the login page with any email address and password.
  2. Submit a new order from the order form.
  3. Go to the view-orders page and confirm that the new order shows your login email address in the "Ordered by" section.

Learning

Describe the research stage

  1. While looking through the redux folder in the repo, I check to see where dispatch is being called in order to update state with auth information.
  2. After finding that dispatch is called within authActions, I notice that the action object contains properties for the type (which is 'login') and a payload (which contains the properties email and token).
  3. I check the reducer function to make sure state is being updated, and notice that the email property in state is being set to action.payload.login. The issue is that login was not a property in our payload, and that it should be action.payload.email instead.

Links to blog posts, patterns, libraries or addons used to solve this problem

Redux Documentation - the official documentation on Redux data flow helped me understand the process of calling dispatch (which runs the store's reducer function) to update state.

Closes Shift3#4

… set form selection for the ordered item and quantity
…ayload.email rather than action.payload.login
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

Successfully merging this pull request may close these issues.

Bug: Retrieve user from Redux and include in Order Form
1 participant