@sonic-equipment/ui 199.0.0 → 200.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { useMemo } from 'react';
|
|
3
4
|
import { IconButton } from '../../../buttons/icon-button/icon-button.js';
|
|
4
5
|
import { useFormattedMessage } from '../../../intl/use-formatted-message.js';
|
|
5
6
|
import { AccountIcon } from '../../../navigation/account-icon/account-icon.js';
|
|
@@ -11,10 +12,16 @@ function ConnectedAccountButton({ className, 'data-test-selector': dataTestSelec
|
|
|
11
12
|
const paths = usePaths();
|
|
12
13
|
const t = useFormattedMessage();
|
|
13
14
|
const isAuthenticated = useIsAuthenticated();
|
|
14
|
-
const
|
|
15
|
+
const _location = useLocation();
|
|
16
|
+
const href = useMemo(() =>
|
|
17
|
+
// TODO: Replace with relative URL when migrated away from Umbraco
|
|
18
|
+
typeof location === 'undefined' ? undefined : location.href,
|
|
19
|
+
// Using the location hook to detect url changes, but not using it directly
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
[_location]);
|
|
15
22
|
return (jsx(IconButton, { className: className, "data-authenticated": isAuthenticated ? true : false, "data-test-selector": dataTestSelector, href: isAuthenticated
|
|
16
23
|
? paths.ACCOUNT
|
|
17
|
-
: `${paths.SIGN_IN}${
|
|
24
|
+
: `${paths.SIGN_IN}${href ? `?returnUrl=${encodeURIComponent(href)}` : ''}`, onClick: onClick, children: jsx(AccountIcon, { "aria-label": isAuthenticated ? t('My Sonic') : t('Sign in or create account'), isAuthenticated: isAuthenticated }) }));
|
|
18
25
|
}
|
|
19
26
|
|
|
20
27
|
export { ConnectedAccountButton };
|