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

[feat] integrated auth with profile context/onboarding #57

Merged
merged 5 commits into from
Dec 3, 2024

Conversation

kevin3656
Copy link
Contributor

@kevin3656 kevin3656 commented Nov 28, 2024

What's new in this PR 🧑‍🌾

Description

Integrated authcontext with profilecontext and onboarding, profile context will only receive profile if a user is logged in, onboarding will only upload if a user is logged in. User is redirected to view plants after onboarding with default view based on has_plot

Screenshots

How to review

files changed are mainly onboarding/page and utils/profileprovider who know use a userid based on auth instead of a hardcoded one. To test run app and login, then go through onboarding and supabase should receive a profile with the logged in users id.

Next steps

  • Styling for onboarding !
  • consider directly including the onboarding review page in the page container to avoid having to pass in so many additional props

Relevant links

Online sources

Related PRs

CC: @ccatherinetan

@ccatherinetan ccatherinetan changed the title feat integrated auth with profile context/onboarding [feat] integrated auth with profile context/onboarding Dec 2, 2024
@ccatherinetan ccatherinetan force-pushed the 54-integrate-auth-context-with-profile-context branch from a13c11d to d312e2a Compare December 3, 2024 06:53
Copy link
Collaborator

@ccatherinetan ccatherinetan left a comment

Choose a reason for hiding this comment

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

looking great; left some remaining action items in the PR description, but will merge now!

const fetchedProfile = await fetchProfileById(userId as UUID);
setProfileData(fetchedProfile);
} catch (error) {
console.error('Error fetching profile:', error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

we might want to do error.message, i.e.
console.error('Error fetching profile:', error.message);


const setProfile = useCallback(async (completeProfile: Profile) => {
try {
const updatedProfile = await upsertProfile(completeProfile);
setProfileData(updatedProfile);
// Update has_plot if necessary by separate logic
} catch (error) {
console.error('Error setting profile:', error);
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's use error.message?
also, we don't need to both console.error AND throw a new error.
Since we're already catching an error from upsertProfile, I think we can just console.error here


useEffect(() => {
loadProfile();
}, [loadProfile]);
if (!authLoading) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

a possible edge case to consider is what if we want to call loadProfile (i.e. outside of this useEffect); perhaps we should handle the !authLaoding check inside loadProfile??

edit: the only place IJP used this was in /login, when deciding where to route the user. In the case of /login, we would already have access to authLoading, so we can leave it as is!

@ccatherinetan ccatherinetan merged commit 83852e8 into main Dec 3, 2024
2 checks passed
@ccatherinetan ccatherinetan linked an issue Dec 4, 2024 that may be closed by this pull request
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.

Integrate Auth Context with Profile Context
2 participants