Gabrielgyimah - #13
Open
gabrielgyimah wants to merge 7 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I implemented the following:
Middleware and related functionality - This is to protect routes we don’t want public users to access. For effectiveness, I made a routes file containing all the routes and put some into a list that are called public, auth or protected routes. The middleware is triggered on every route and based on whether the current route is public or not, it checks if the user is authenticated by an API call to the /validate-token endpoint and give access if user is verified.
User context - For easy access and to prevent unnecessary calls to the user’s endpoint to get user data every time there’s need for it, I implemented the global user context which means when the application loads, a call is made to the backend to retrieve user data once and it is available all through the app by using const { user } = useUser().
Dynamic Organization Context - The dynamic organization context is to make a single organization object available all through the /organization/organizationId route and all of its nested routes like /sales, /purchases, etc.
it is accessible across the dynamic routes by using just { organization, loading, error } = useOrganization()
Notes: loading is to get a state the data fetching is ongoing so we can perhaps show a loading animation. error is when the organization is not found or an error occurs and we can show them some error or whatever we decide.
Also, the functionality that fetches the organization data uses useEffect and the bug here is that it continues to trigger when the organization is not found. The next step is to work on that.
Complete Login - I’ve connected the login functionalities to the backend and they are fully working.
Complete Sign up - I have also completed the signup functionality.
Password reset - This is also done
A few other functions.