diff --git a/Containers/UserSettings/UsernameSettings/UsernameSettings.js b/Containers/UserSettings/UsernameSettings/UsernameSettings.js index 1733528..71bd92a 100644 --- a/Containers/UserSettings/UsernameSettings/UsernameSettings.js +++ b/Containers/UserSettings/UsernameSettings/UsernameSettings.js @@ -8,6 +8,7 @@ import { SpinnerDotted } from 'spinners-react'; //Components import Error from '../../../Components/UI/Error/Error'; +import Info from '../../../Components/UI/Info/Info'; export default function UsernameSettings(props) { //Var @@ -25,12 +26,14 @@ export default function UsernameSettings(props) { register, handleSubmit, control, + reset, formState: { errors, isSubmitting, isValid }, } = useForm({ mode: 'onChange' }); ////State const [isLoading, setIsLoading] = useState(false); const [error, setError] = useState(); + const [info, setInfo] = useState(false); ////Functions //Form submit Handler for ADD a repo @@ -57,7 +60,8 @@ export default function UsernameSettings(props) { } else { reset(); setIsLoading(false); - toast.success('Email edited !', { + setInfo(true); + toast.success('Username edited !', { position: 'top-right', autoClose: 5000, hideProgressBar: false, @@ -77,42 +81,62 @@ export default function UsernameSettings(props) {
-
-

- {error && } - - {errors.email && - errors.email.type === 'required' && ( + {info ? ( + //For local JWTs (cookie) without an OAuth provider, Next-Auth does not allow + //at the time this code is written to refresh client-side session information + //without triggering a logout. + //I chose to inform the user to reconnect rather than force logout. + + ) : ( + +

+ {error && } + + {errors.username && errors.username && ( - This field is required. + {errors.username.message} )} -

- -
+

+ + + )}