diff --git a/src/components/account/login/AccountLogin.js b/src/components/account/login/AccountLogin.js index ecac004b..1dc96bd4 100644 --- a/src/components/account/login/AccountLogin.js +++ b/src/components/account/login/AccountLogin.js @@ -68,7 +68,11 @@ export const AccountLogin = ({ history }) => { const { meta } = await dispatch(setLogin(loginForm)); if (meta.requestStatus === 'fulfilled') { - history.push('/control'); + if (loginForm?.userId === 'dos-gmp') { + history.push('/flight/Approvals/new'); + } else { + history.push('/control'); + } } }; diff --git a/src/router/hoc/authenticationCheck.tsx b/src/router/hoc/authenticationCheck.tsx index 4aeb6e0e..a1d8a76b 100644 --- a/src/router/hoc/authenticationCheck.tsx +++ b/src/router/hoc/authenticationCheck.tsx @@ -1,5 +1,5 @@ import { ReactNode, useEffect, useLayoutEffect, useState } from 'react'; -import { RouteComponentProps } from 'react-router-dom'; +import { RouteComponentProps, useHistory } from 'react-router-dom'; import { useSelector, useDispatch } from '@src/redux/store'; import { checkToken } from '@src/redux/features/account/auth/authThunk'; import { ICheckAuthencationRs } from '@src/redux/features/account/auth/authState'; @@ -23,6 +23,7 @@ interface IProps extends RouteComponentProps { export default function (SpecificComponent: ReactNode, option: IOption) { function AuthenticationCheck(props: RouteComponentProps) { const dispatch = useDispatch(); + const history = useHistory(); const { user } = useSelector(state => state.authState); const [isRender, setIsRender] = useState(false); @@ -60,6 +61,17 @@ export default function (SpecificComponent: ReactNode, option: IOption) { }; }, []); + useLayoutEffect(() => { + if (user?.cptAuthCode === 'DF0002') { + const pathname = history.location.pathname; + + if (pathname != '/flight/Approvals/new') { + props.history.replace('/flight/Approvals/new'); + return; + } + } + }, [user]); + return <>{isRender ? : null}; } return AuthenticationCheck;