@antscorp/antsomi-ui 1.3.5-beta.549 → 1.3.5-beta.550

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.
@@ -29,6 +29,7 @@ import { Helmet } from 'react-helmet';
29
29
  import { useCookies } from 'react-cookie';
30
30
  import dayjs from 'dayjs';
31
31
  import html2canvas from 'html2canvas';
32
+ import { useLocation, useParams } from 'react-router-dom';
32
33
  // Styled
33
34
  import { ChildrenWrapper, ContentWrapper, LayoutWrapper, NotificationWrapper } from './styled';
34
35
  // Components
@@ -45,7 +46,7 @@ import '@antscorp/processing-notification/dist/index.css';
45
46
  import { useLayoutStore } from './stores';
46
47
  // Utils
47
48
  import { hasSelectAccountPermission } from './utils';
48
- import { useCustomRouter, useDeepCompareMemo, useMutationObserver, } from '@antscorp/antsomi-ui/es/hooks';
49
+ import { useCustomRouter, useDeepCompareEffect, useDeepCompareMemo, useMutationObserver, } from '@antscorp/antsomi-ui/es/hooks';
49
50
  import { HOME_MENU_ITEMS } from '../../organism/LeftMenu/constants';
50
51
  import { RecommendationWorkspace } from './components';
51
52
  import i18nInstance from '@antscorp/antsomi-ui/es/locales/i18n';
@@ -63,7 +64,9 @@ export const Layout = memo(props => {
63
64
  const contentWrapper = useLayoutStore(store => store.state.contentWrapper);
64
65
  const workspace = useLayoutStore(store => store.state.workspace);
65
66
  const [, , removeCookie] = useCookies();
66
- const { navigate } = useCustomRouter();
67
+ const params = useParams();
68
+ const location = useLocation();
69
+ const { navigate, replace } = useCustomRouter();
67
70
  const [showAccountSelection, setShowAccountSelection] = useState(false);
68
71
  const [noSpaceTopContent, setNoSpaceTopContent] = useState(false);
69
72
  const [activeMenu, setActiveMenu] = useState(null);
@@ -162,6 +165,14 @@ export const Layout = memo(props => {
162
165
  setIsAccessDenied(isAccessDenied);
163
166
  }
164
167
  }, [onActiveMenuChange]);
168
+ // Effects
169
+ /** Handle replace current userId in params if current userId is not match */
170
+ useDeepCompareEffect(() => {
171
+ const { userId: userIdParam } = (params || {});
172
+ if (userIdParam && userId && userIdParam !== userId && location.pathname) {
173
+ replace(`${location.pathname.replace(userIdParam, `${userId}`)}${location.search}`);
174
+ }
175
+ }, [params, location, userId, navigate, replace]);
165
176
  // Handle access denied
166
177
  const onClickSwitchAccount = useCallback(() => {
167
178
  // Remove cookie when switch account
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antscorp/antsomi-ui",
3
- "version": "1.3.5-beta.549",
3
+ "version": "1.3.5-beta.550",
4
4
  "description": "An enterprise-class UI design language and React UI library.",
5
5
  "sideEffects": [
6
6
  "dist/*",