nextjs-subscription-payments
nextjs-subscription-payments copied to clipboard
Account Details Update Buttons
Feature request
The account details page is set up to imply that you can update your account. Entry forms and buttons that actually update these things in the database would be nice.
Describe the solution you'd like
An example of updating the name (so I can implement the email update), or full implementation by default.
Describe alternatives you've considered
Currently going to try to write it myself based on the handleSignUp logic.
Additional context
Upon a local implementation and initial signup - the Full Name didn't get added to the database. When I went to manually do it in account details, there's no buttons - thus the request.
Thanks for the starter and the project. Solves some serious headaches and is very very cool.
@andrewshrout I ran into this as well. Did you end up adding this to the account page or modifying handleSignUp to update full_name in the DB when signing up?
It's not too much work to expose the information to update it. You just need to call update from the Supabase client. To do this, I did the following:
- Create a React state for a text field to enter the user's full name and a button that updates the full name when it's clicked.
- Expose
setUserDetailsinuseUser.tsx, to make change once I update the database.
The function that I call looks like this:
async function updateUser({fullName}: {fullName: string}) {
setLoading(true)
try {
const { error } = await supabase.from('users').update({full_name: fullName}).match({id: user.id});
if (error) {
throw error
}
const newUserDetails = {...userDetails, full_name: fullName}
setUserDetails(newUserDetails as UserDetails)
} catch (error) {
if (error) return alert((error as Error).message);
}
setLoading(false)
}
I'm sure there's a better way to tie into React contexts (and I'd love any advice on this), but this seems to work for now. Hopefully this helps.
Going to leave this as is for now, but we might reconsider in the future 🙏