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

wip #40 - Added nav bar #52

Merged
merged 1 commit into from
Feb 3, 2017
Merged

wip #40 - Added nav bar #52

merged 1 commit into from
Feb 3, 2017

Conversation

simon-bourque
Copy link
Collaborator

@simon-bourque simon-bourque commented Feb 2, 2017

I added the nav bar and it only shows up when the user logs in, We need to do some cleanup in UserReducer because I really needed to add a new boolean to get the nav bar to hide properly. The way the json is set up for our store is very messy and all over the place atm.

I rather just be able to check whether user in our store is null or not as opposed to having an extra boolean but its not in the initial state and its added in a very weird place (data.user but data is an array?)

@@ -14,12 +14,15 @@ const UserReducer = (state = initialState, action) => {
let data = [...state.data];
if(action.response.statusCode == 200){
data.user = action.response.user;
state.loggedIn = true;
Copy link
Owner

Choose a reason for hiding this comment

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

why not just check if the data.user prop is set? also later on we will be using cookies for this so it might require additional refactoring.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's what I wanted todo, but thing is data.user is not declared until the first logging, but im having trouble adding data.user to the initial state. I think we need to fix it up, Is data necessary, can we just have user instead of data.user?

Copy link
Owner

Choose a reason for hiding this comment

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

data isn’t necessary but since redux only keeps one giant store, adding sub-objects is our way of creating sub-stores.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the sub-store is users, so it would be users.data.user, and also data is an empty array so its weird, were adding user as a member of data and not in the array itself

Copy link
Owner

Choose a reason for hiding this comment

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

Hmm, yeah that is weird, we should probably make it an empty object instead. Why do you suggest users.data.user seems like an even larger complication no?

Copy link
Owner

Choose a reason for hiding this comment

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

Requires redesign in my opinion lol.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I agree as well, this is what I wanted to bring up with my initial comment lol, but i think redux is the one splitting it by reducer, but if everyone gives me permission id like to remove users.data.user and replace it with just users.user

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

that way it becomes trivial to add user : null to the initial state and I can just use a simple null check for the navbar

Copy link
Owner

Choose a reason for hiding this comment

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

I see benefit in refactoring this, just make sure to create an issue for it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Owner

@jacobrs jacobrs left a comment

Choose a reason for hiding this comment

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

The logout redirects but doesn't remove the loggedIn value from the store. Thought that should be noted but isn't really part of this issue. Apart from that, looks good, might need some additional design work from @sam so I wouldn't close the issue yet.

@jacobrs jacobrs added this to the Sprint 2 milestone Feb 3, 2017
@simon-bourque
Copy link
Collaborator Author

@jacobrs Yup it still needs the design, its just a placeholder for now, a log out action is still required as well

@MartinSpasov MartinSpasov mentioned this pull request Feb 3, 2017
2 tasks
@simon-bourque simon-bourque merged commit e02c5ec into master Feb 3, 2017
@simon-bourque simon-bourque deleted the navbar branch February 3, 2017 18:10
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.

None yet

2 participants