Skip to content

Commit

Permalink
Try async/await
Browse files Browse the repository at this point in the history
  • Loading branch information
cmyui committed Aug 8, 2024
1 parent a56498e commit b259e44
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/pages/UserSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,14 @@ const ChangeFormButton = ({
onClose={handleClose}
PaperProps={{
component: "form",
onSubmit: (event: FormEvent<HTMLFormElement>) => {
onSubmit: async (event: FormEvent<HTMLFormElement>) => {
event.preventDefault()
const formData = new FormData(event.currentTarget)
const formJson = Object.fromEntries(formData.entries())
const newValue = formJson[fieldName]
// TODO: potentially automatically validate debounced input
// is available server-side as-they-type?
onSubmit(newValue.toString())
await onSubmit(newValue.toString())
handleClose()
},
}}
Expand Down Expand Up @@ -147,8 +147,8 @@ export const UserSettingsPage = () => {
displayName="Username"
inputType="text"
autoComplete="username"
onSubmit={(newValue) => {
updateUsername(pageUserId, newValue)
onSubmit={async (newValue) => {
await updateUsername(pageUserId, newValue)
if (identity !== null) {
setIdentity({ ...identity, username: newValue })
}
Expand All @@ -160,16 +160,18 @@ export const UserSettingsPage = () => {
displayName="Password"
inputType="password"
autoComplete="new-password"
onSubmit={(newValue) => updatePassword(pageUserId, newValue)}
onSubmit={async (newValue) =>
await updatePassword(pageUserId, newValue)
}
/>
<Divider />
<ChangeFormButton
fieldName="email"
displayName="Email Address"
inputType="email"
autoComplete="email"
onSubmit={(newValue) =>
updateEmailAddress(pageUserId, newValue)
onSubmit={async (newValue) =>
await updateEmailAddress(pageUserId, newValue)
}
/>
</Stack>
Expand Down

0 comments on commit b259e44

Please sign in to comment.