BloomTech-Labs/lets-get-pizza-fe

Add button for Event/Promotion/Reviews on Business Page missing

Closed this issue · 3 comments

This is located in the MainBar component. showAddButton determines if the button shows or not. Will need to investigate further.

This is because the newly added Redux authentication actions do not create the curr_user or curr_location Local Storage items. I would suggest using the authenticateUser helper function located in utils/auth.js as it sets it automatically and redirects the user to a specific page.

A suggested fix in redux/actions/locationsActions.js:

import * as types from "../types";
import API, { authenticateUser } from "../../utils/auth.js";

API.post("auth/location/login", { username, password })
  .then(res => {
    dispatch({ type: types.LOGIN_SUCCESS, payload: res.data.location });
    authenticateUser(res);
  })
  .catch(err => {
    dispatch({ type: types.LOGIN_FAIL, payload: false });
  });

Another idea is to modify LocationPage so that the currUser and currLocation props point to their respective Redux state instead of the direct Local Storage items, and instead you simply hydrate Redux state from Local Storage when it is first initialized.

I went ahead and refactored the LocationPage component to point to the correct user and location state inside of Redux