diff --git a/src/components/MyAccount/NewSettings/StatusBanner.tsx b/src/components/MyAccount/NewSettings/StatusBanner.tsx
index ee8e965b2..78b0b2294 100644
--- a/src/components/MyAccount/NewSettings/StatusBanner.tsx
+++ b/src/components/MyAccount/NewSettings/StatusBanner.tsx
@@ -7,35 +7,45 @@ type StatusBannerProps = {
statusMessage: string
}
+const successContent = (
+
+ Your changes were saved.
+
+)
+
+const generalFailureContent = (
+
+ Your changes were not saved.
+
+)
+
+const specificFailureContent = (statusMessage: string) => {
+ return (
+
+ {statusMessage} Please try again or{" "}
+
+ contact us
+ {" "}
+ for assistance.
+
+ )
+}
+
export const StatusBanner = ({ status, statusMessage }: StatusBannerProps) => {
const bannerContent = (
- {status === "failure" ? (
- statusMessage !== "" ? (
-
- {statusMessage} Please try again or{" "}
-
- contact us
- {" "}
- for assistance.
-
- ) : (
-
- Your changes were not saved.
-
- )
- ) : (
-
- Your changes were saved.
-
- )}
+ {status === "failure"
+ ? statusMessage !== ""
+ ? specificFailureContent(statusMessage)
+ : generalFailureContent
+ : successContent}
)
diff --git a/src/components/MyAccount/NewSettings/UsernameForm.tsx b/src/components/MyAccount/NewSettings/UsernameForm.tsx
index 600cff88d..1afe3dd5b 100644
--- a/src/components/MyAccount/NewSettings/UsernameForm.tsx
+++ b/src/components/MyAccount/NewSettings/UsernameForm.tsx
@@ -101,6 +101,94 @@ const UsernameForm = ({ patron, usernameState }: UsernameFormProps) => {
}
}
+ const editUsernameField = (
+ <>
+
+ setError(true)}
+ />
+
+
+
+ >
+ )
+
+ const notEditingView = (
+
+ {input !== "" ? (
+ <>
+
+ {input}
+
+ setIsEditing(true)}
+ />
+ >
+ ) : (
+ {
+ setIsEditing(true)
+ setTempInput("")
+ }}
+ />
+ )}
+
+ )
+
+ const editingView = (
+
+ {tempInput !== null ? (
+ editUsernameField
+ ) : (
+ {
+ setTempInput("")
+ }}
+ />
+ )}
+
+ )
+
return (
{
{isLoading ? (
) : isEditing ? (
-
- {tempInput !== null ? (
- <>
-
- setError(true)}
- />
-
-
-
- >
- ) : (
- {
- setTempInput("")
- }}
- />
- )}
-
+ editingView
) : (
-
- {input !== "" ? (
- <>
-
- {input}
-
- setIsEditing(true)}
- />
- >
- ) : (
- {
- setIsEditing(true)
- setTempInput("")
- }}
- />
- )}
-
+ notEditingView
)}
{isEditing && (