-
Notifications
You must be signed in to change notification settings - Fork 93
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
Feat: View/Create and Update Organization Profile #69
Feat: View/Create and Update Organization Profile #69
Conversation
Update @anitab-org/bridgeintech-maintainers . I've completed View/Create/Update Organization profile on this one PR. Since we only have one week to go to complete the project features, I'll move on to the next functionalities first which are the View organizations and view other organization profile (where user has selected the organization name from the Organizations list). |
@meenakshi-dhanani and @ramitsawhney27 , I want to point out that atm I didn't show the |
Getting back to the earlier discussion, it wasn't just about keeping the detail in the backend. One thing we agreed on was keeping it in one place. Since all of the timezone information was all on the backend, we chose to not do a larger change and thus stuck to having it in the backend. If it's not your core business logic though, and if it's presentation logic feel free to do things on the frontend. In this case I don't have a strong reason for why the calculation needs to be in the frontend, though I usually have seen APIs returning readable dates from the backend, eg. 2020-01-06T20:22:05.000Z. While using the API, just as an API, it's far more convenient to have in human readable format. I'd prefer backend. |
Thanks, @meenakshi-dhanani for sharing your thoughts. @ramitsawhney27, can I also please have your thoughts on this? If we decide to do the logic at the backend, before moving to creating View and Update Programs on frontend, I'll refactor the relevant date related fields on any endpoints that are currently using the unix dates to accept the human readable format (perhaps RFC 2822: Thursday, 31-Dec-20 00:00:00 UTC). But the database will be kept in double precision format. |
We use context when there is some global state that we want a lot of components to use, eg. login, logout, etc. If a user is a representative, is this state required across the application? In case a user is a representative, should one call suffice? Is it really necessary to keep it in context? |
What we can do is shift the My Organization as a separate submenu inside My Space. We can simply show that irrespective of whether a user is a representative or no, if a user is not representative, let that page not show up. If the user is a representative then let's show the form. |
@meenakshi-dhanani . is_organization_representative in the frontend is used to set thee Navbar which is re-rendered on each pages user go to. So, in this case, I would say, yes, the value needs to be placed in Context.
as per the answer above, it's needed on the Navbar
Yeah, I think keeping it in AuthContext will suffice. Do you agree? |
On this point, @meenakshi-dhanani , since the Navbar menu gets re-rendered every time user go to different pages, the submenu My Organisation will be checked against the is_organization_rep every time a new page is rendered. If not in AuthContext, how would you suggest we keep the value of this attribute? |
What I'm suggesting is this need not be in the navbar for now. You can keep my organization inside my space. Similar to how you handle personal information. If a user doesn't have any information you say that the user is not a representative, if the user wants to be then the user must check the box in additional details. If the user is then show the form. Also, the fact that a user is representative can be received via an API call that could be made. The responsibility of the AuthContext is not to keep other fields, it's just the access token that is very tightly coupled with authentication. So definitely not inside AuthContext. You could do an api call that includes in it's response - is_representative details Also the responsibility and expected payload of a login API is not to return the is_representative_flag. So in both ways it's not right |
Ok, Can you please open a PR for the refactoring? both on backend and frontend? I'll do it post GSoC. |
@meenakshi-dhanani Thanks for your help sorting out the Navbar. I've merged the PR you raised to this one. Can you please re-review? Thanks. cc @anitab-org/bridgeintech-maintainers |
src/AuthContext.js
Outdated
@@ -36,6 +37,7 @@ function AuthProvider({ children }) { | |||
Cookies.remove("user"); | |||
Cookies.remove("access_token"); | |||
Cookies.remove("access_expiry"); | |||
Cookies.remove("is_organization_representative"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line should not be there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It's now removed
We just need to remove that line in AuthContext, and I will approve |
Done that, @meenakshi-dhanani . |
6ad5a14
to
742ce0b
Compare
@ramitsawhney27 all changes LGTM, can you approve if it looks fine? |
@isabelcosta I have attached the .gif above that shows the following:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the latest pull and ran again, I had missed the following scenario:
If a organization does not exist for a user, allow the user to create the organization when Organization profile is clicked under my organization. This is breaking, needs to be fixed.
@meenakshi-dhanani can you explain the bug a little bit more, I didn't understand your sentence 😕 |
remove is_representative from cookie and fix navigation Remove is_organization_rep fix Create Organization
742ce0b
to
b7d74ca
Compare
@meenakshi-dhanani , I've fixed the initial page rendering so user can fill in the form to create organization if they haven't create one (just as what I had before the Navbar fix as can be seen in this PR description) |
@isabelcosta The bug I reported, was about a user, that says that he/she/they are representing an organization, but have no organization created. The expected behavior would be to see a create organization form for them. Maya has pushed the fix for that now. So that is working with the fix. I have tested the following scenarios:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes made in this PR were tested locally. Following are the results:
Description
Added View Organization Profile Functionality
Fixes #50, #51
Type of Change:
Code/Quality Assurance Only
How Has This Been Tested?
Save
. On successful create, see response below.To check if the data is saved to database, move away from the MyOrganization Profile page (click on any other page) and comeback. See response below:
![Screen Shot 2020-08-17 at 3 41 19 pm](https://user-images.githubusercontent.com/29667122/90361594-f69c0d00-e0a1-11ea-84ad-342a0e40a8a5.png)
Save
. On successful update, see response below:to check if the data is updated, move away from thee MyOrganization Profile page (click on any other page) and comeback. See response below:
![Screen Shot 2020-08-17 at 3 41 48 pm](https://user-images.githubusercontent.com/29667122/90361729-4a0e5b00-e0a2-11ea-8523-b12fc3e4bf51.png)
Checklist:
Code/Quality Assurance Only
Additional note:
This PR is to be tested with the Backend server from PR#112 only since it contains the refactored login with successful response returning
is_organization_representative
value.