-
Notifications
You must be signed in to change notification settings - Fork 2
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
[feat] integrated auth with profile context/onboarding #57
Conversation
a13c11d
to
d312e2a
Compare
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.
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); |
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.
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); |
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.
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) { |
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.
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!
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
Relevant links
Online sources
Related PRs
CC: @ccatherinetan