Skip to content

Conversation

eonminion
Copy link

This pull request introduces enhancements to the settings components by adding an onSave callback prop across multiple components. This allows developers to execute custom logic after successful updates (e.g., email, password, username changes). Additionally, it includes documentation updates and minor code formatting improvements.

Enhancements to Component Functionality:

  • Added an onSave callback prop to the following components: UpdateFieldCard, UpdateNameCard, UpdateUsernameCard, ChangeEmailCard, and ChangePasswordCard. This prop allows custom logic to be executed after successful updates, such as closing dialogs or refreshing user data. ([[1]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-5c8cd3d988f41f9f4eead8739b070e61dd934b7d3060a7258aec41438d0a408cL41-R42), [[2]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-5c8cd3d988f41f9f4eead8739b070e61dd934b7d3060a7258aec41438d0a408cL56-R58), [[3]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-5c8cd3d988f41f9f4eead8739b070e61dd934b7d3060a7258aec41438d0a408cR155-R162), [[4]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-759e5215377903309c11507d36bf32fa9c5c9e9d472376e498eb516ac242b052R12), [[5]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-759e5215377903309c11507d36bf32fa9c5c9e9d472376e498eb516ac242b052R37), [[6]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-b1f75c01668212152ba2d42254614cef7965a03015a9003985b96af5e411eb35L1-R18), [[7]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-b1f75c01668212152ba2d42254614cef7965a03015a9003985b96af5e411eb35R32-R35), [[8]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-ef8f2bd0f57af21e02524cac14c291c6bd5885872d73b7ba202828bd98609641R26), [[9]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-ef8f2bd0f57af21e02524cac14c291c6bd5885872d73b7ba202828bd98609641R123-R137), [[10]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-ef8f2bd0f57af21e02524cac14c291c6bd5885872d73b7ba202828bd98609641L182-R194), [[11]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-023b3910db4d4eee4bb9f1d45234ebfee80845ca6c5671e093238081879edd0fR36), [[12]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-023b3910db4d4eee4bb9f1d45234ebfee80845ca6c5671e093238081879edd0fL45-R47), [[13]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-023b3910db4d4eee4bb9f1d45234ebfee80845ca6c5671e093238081879edd0fR171-R185), [[14]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-023b3910db4d4eee4bb9f1d45234ebfee80845ca6c5671e093238081879edd0fL188-R201), [[15]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-159fb75f86ec54f3e7bfbb8b782f4b954874e7172e4fe24c18f3ea928131d9cbR56))

Documentation Updates:

  • Updated the documentation for ChangeEmailCard, ChangePasswordCard, and UpdateUsernameCard to include examples of using the onSave prop, showcasing its utility in scenarios like closing dialogs or redirecting users. ([[1]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-86a580f849eaa3135d3b75ae4225aeb6d8476a9db8d4e267a4daaa0bf57fef45L63-R103), [[2]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-5cf061453caea01fdaa17113d0a268bb24a57b36671ee3687a4366239c88c2f6L75-R117), [[3]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-4f7a92974e45c7eb250065986be3bac17a28a07648b14106948d914c0f004eb9R46-R76))
  • Improved code formatting in the documentation examples for ChangeEmailCard and ChangePasswordCard to enhance readability. ([[1]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-86a580f849eaa3135d3b75ae4225aeb6d8476a9db8d4e267a4daaa0bf57fef45L7-R30), [[2]](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-5cf061453caea01fdaa17113d0a268bb24a57b36671ee3687a4366239c88c2f6L7-R30))

Code Formatting Improvements:

  • Standardized import statements and added semicolons in UpdateUsernameCard for consistent code style. ([src/components/settings/account/update-username-card.tsxL1-R18](https://github.com/daveyplate/better-auth-ui/pull/121/files#diff-b1f75c01668212152ba2d42254614cef7965a03015a9003985b96af5e411eb35L1-R18))

@daveycodez
Copy link
Contributor

My main feedback is that we don't need to add the new "handle" functions. Just call onSave?.() after the success toasts

@eonminion
Copy link
Author

Okay, I will revise this. I try not to modify or add anything to your original functions

@eonminion
Copy link
Author

@daveycodez Hi, can you please review this and let me know if it can be merged

Copy link
Contributor

Choose a reason for hiding this comment

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

Just need to delete this bun file or put in in gitignore

})
}

onSave?.()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this onSave should be called inside the try block? Since after catching the error would be a failure

Copy link
Contributor

Choose a reason for hiding this comment

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

This file needs to be formatted with the Biome configuration

setResendDisabled(false)
throw error
}
onSave?.()
Copy link
Contributor

Choose a reason for hiding this comment

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

Should also probably be at the bottom of the try block instead of after catching

Copy link
Contributor

Choose a reason for hiding this comment

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

Same issue with onSave being after catching the error instead of inside the try block. Not sure if that's intentional. onSave should probably only be called after a success

@daveycodez
Copy link
Contributor

I can merge this once the above comments are resolved

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.

2 participants