Skip to content

Commit

Permalink
Merge pull request #425 from NYPL/main
Browse files Browse the repository at this point in the history
My Account 2.0 QA #3
  • Loading branch information
7emansell authored Dec 20, 2024
2 parents 986f582 + 626168b commit c4b7f59
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 43 deletions.
10 changes: 10 additions & 0 deletions src/components/MyAccount/Settings/PasswordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,21 @@ const PasswordForm = ({ patronData, settingsState }: PasswordFormProps) => {

const cancelEditing = () => {
setIsEditing(false)
clearForm()
setEditingField("")
setTimeout(() => {
editingRef.current?.focus()
}, 0)
}

const clearForm = () => {
setFormData({
currentPassword: "",
newPassword: "",
confirmPassword: "",
passwordsMatch: true,
})
}
const validateForm =
formData.currentPassword !== "" &&
formData.newPassword !== "" &&
Expand Down Expand Up @@ -146,6 +155,7 @@ const PasswordForm = ({ patronData, settingsState }: PasswordFormProps) => {
console.error("Error submitting", error)
} finally {
setIsLoading(false)
clearForm()
setEditingField("")
}
}
Expand Down
88 changes: 45 additions & 43 deletions src/components/MyAccount/Settings/SettingsSelectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -190,50 +190,52 @@ const SettingsSelectForm = ({
</Select>
</Flex>
) : (
<Flex marginLeft={{ base: "m", lg: "unset" }}>
<Flex flexDir="column">
<Text
sx={{
marginTop: { base: "xs", lg: "unset" },
width: { base: "200px", sm: "250px" },
marginBottom: 0,
}}
>
{selection}
</Text>
{isNotification &&
patronHasNonePref &&
!patronHasPhone &&
!patronHasEmail && (
<Banner
sx={{
marginTop: "s",
width: { base: "200px", sm: "250px" },
}}
content="Please set a phone number or email address to choose a notification preference."
/>
)}
<Flex flexDir="column">
<Flex marginLeft={{ base: "m", lg: "unset" }}>
<Flex flexDir="column">
<Text
sx={{
marginTop: { base: "xs", lg: "unset" },
width: { base: "200px", sm: "250px" },
marginBottom: 0,
}}
>
{selection}
</Text>
</Flex>
{editingField === "" && (
<EditButton
isDisabled={
isNotification &&
patronHasNonePref &&
!patronHasPhone &&
!patronHasEmail
}
ref={editingRef}
buttonLabel={`Edit ${type}`}
buttonId={`edit-${type}-button`}
onClick={() => {
setIsEditing(true)
setEditingField(type)
setTimeout(() => {
selectRef.current?.focus()
}, 0)
}}
/>
)}
</Flex>
{editingField === "" && (
<EditButton
isDisabled={
isNotification &&
patronHasNonePref &&
!patronHasPhone &&
!patronHasEmail
}
ref={editingRef}
buttonLabel={`Edit ${type}`}
buttonId={`edit-${type}-button`}
onClick={() => {
setIsEditing(true)
setEditingField(type)
setTimeout(() => {
selectRef.current?.focus()
}, 0)
}}
/>
)}
{isNotification &&
patronHasNonePref &&
!patronHasPhone &&
!patronHasEmail && (
<Banner
sx={{
width: { base: "80%", sm: "320px" },
marginLeft: { base: "m", lg: "unset" },
}}
content="Please set a phone number or email address to choose a notification preference."
/>
)}
</Flex>
)}
{isEditing && (
Expand Down

0 comments on commit c4b7f59

Please sign in to comment.