Browse Source

로그인 풀리는 현상 수정

master
김장현 3 months ago
parent
commit
001f98814d
  1. 41
      src/containers/flight/NewFlightApprovalsContainer.js
  2. 28
      src/router/hoc/authenticationCheck.tsx
  3. 7
      src/router/routes/RouteFlight.js

41
src/containers/flight/NewFlightApprovalsContainer.js

@ -33,7 +33,7 @@ export default function NewFlightApprovalsContainer({ mode }) {
const [mapObject, setMapObject] = useState(); const [mapObject, setMapObject] = useState();
const { areaCoordList, isOpenModal } = useSelector(state => state.laancState); const { areaCoordList, isOpenModal } = useSelector(state => state.laancState);
const { user } = useSelector(state => state.authState);
// //
const [startDate, setStartDate] = useState(dayjs().format('YYYY-MM-DD')); const [startDate, setStartDate] = useState(dayjs().format('YYYY-MM-DD'));
const [endDate, setEndDate] = useState(); const [endDate, setEndDate] = useState();
@ -48,6 +48,9 @@ export default function NewFlightApprovalsContainer({ mode }) {
const [isPopup, setIsPopup] = useState(false); const [isPopup, setIsPopup] = useState(false);
const [popup, setPopup] = useState(null); const [popup, setPopup] = useState(null);
const popupRef = useRef(null); const popupRef = useRef(null);
const rightMenuRef = useRef(null);
const savedRightMenuRef = useRef(null);
const [clientX, setClientX] = useState(0);
const previewGeo2 = { const previewGeo2 = {
type: 'FeatureCollection', type: 'FeatureCollection',
@ -117,12 +120,38 @@ export default function NewFlightApprovalsContainer({ mode }) {
} }
}; };
let timer; let timer;
if (rightMenuRef.current) {
savedRightMenuRef.current = rightMenuRef.current.getBoundingClientRect();
}
if (popup) { if (popup) {
timer = setInterval(() => { timer = setInterval(() => {
if (popup.closed) { if (popup.closed) {
setIsPopup(false); setIsPopup(false);
clearInterval(timer); clearInterval(timer);
} }
if (savedRightMenuRef.current) {
console.log('@?@?@?');
// 부모 창의 특정 영역 (right-layer)의 위치와 크기
const specificArea = {
left: window.screenX + window.outerWidth - clientX, // 영역을 넓게 설정
right: window.screenX + window.outerWidth - clientX
};
console.log(specificArea);
// 팝업 창의 현재 위치
const popupRightEdge = popup.screenX + popup.outerWidth;
// window.screenX + window.outerWidth - e.clientX
console.log(popupRightEdge);
// console.log('Popup Position:', { popupLeft, popupTop });
if (
popupRightEdge >= specificArea.left &&
popupRightEdge <= specificArea.right
) {
setIsPopup(false);
clearInterval(timer);
}
}
}, 1000); // 1초마다 체크 }, 1000); // 1초마다 체크
} }
window.addEventListener('message', childMessage); window.addEventListener('message', childMessage);
@ -132,7 +161,7 @@ export default function NewFlightApprovalsContainer({ mode }) {
window.removeEventListener('message', childMessage); window.removeEventListener('message', childMessage);
}; };
}, [popup]); }, [popup]);
console.log(history);
useEffect(() => { useEffect(() => {
const handleBeforeUnload = e => { const handleBeforeUnload = e => {
localStorage.removeItem('persist:root'); localStorage.removeItem('persist:root');
@ -155,11 +184,12 @@ export default function NewFlightApprovalsContainer({ mode }) {
const popupWidth = el.offsetWidth; // 팝업의 너비 const popupWidth = el.offsetWidth; // 팝업의 너비
const popupHeight = el.offsetHeight; // 팝업의 너비 const popupHeight = el.offsetHeight; // 팝업의 너비
// const popupX = window.screenX + window.outerWidth - e.clientX; // 오른쪽 끝에 띄우기 // const popupX = window.screenX + window.outerWidth - e.clientX; // 오른쪽 끝에 띄우기
// const popupY = Math.round( // const popupY = Math.round(
// window.screenY + window.outerHeight / 2 - popupHeight / 2 // window.screenY + window.outerHeight / 2 - popupHeight / 2
// ); // );
setClientX(window.screenX + window.outerWidth - e.clientX);
const popupX = const popupX =
window.screenX + window.screenX +
(window.outerWidth - popupWidth) / 2 + (window.outerWidth - popupWidth) / 2 +
@ -298,7 +328,10 @@ export default function NewFlightApprovalsContainer({ mode }) {
</div> </div>
{!isPopup && ( {!isPopup && (
<div className='right-menu active'> <div className='right-menu active'>
<div className='right-layer active flight-approval-layer'> <div
className='right-layer active flight-approval-layer'
ref={rightMenuRef}
>
<div className='layer-content'> <div className='layer-content'>
<NewFlightApprovalsReport <NewFlightApprovalsReport
handlerSearch={handlerSearch} handlerSearch={handlerSearch}

28
src/router/hoc/authenticationCheck.tsx

@ -31,11 +31,22 @@ export default function (SpecificComponent: ReactNode, option: IOption) {
props: IProps props: IProps
) => JSX.Element; ) => JSX.Element;
useEffect(() => { useLayoutEffect(() => {
if (props.match.path === '/account/login') { if (user?.cptAuthCode === 'DF0002') {
setIsRender(true); const pathname = history.location.pathname;
if (pathname != '/flight/Approvals/new') {
props.history.replace('/flight/Approvals/new');
return; return;
} }
}
}, [user]);
useEffect(() => {
// if (props.match.path === '/account/login') {
// setIsRender(true);
// return;
// }
dispatch(checkToken() as any).then(({ payload }) => { dispatch(checkToken() as any).then(({ payload }) => {
try { try {
// 로그인 해야만 접근 가능한 페이지인지 체크하는 옵션 // 로그인 해야만 접근 가능한 페이지인지 체크하는 옵션
@ -61,17 +72,6 @@ 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 ? <Component {...props} user={user} /> : null}</>; return <>{isRender ? <Component {...props} user={user} /> : null}</>;
} }
return AuthenticationCheck; return AuthenticationCheck;

7
src/router/routes/RouteFlight.js

@ -1,13 +1,6 @@
import { lazy } from 'react'; import { lazy } from 'react';
const RouteFlight = [ const RouteFlight = [
{
path: '/flight/approvals',
component: lazy(() => import('../../views/flight/FlightView')),
meta: {
authRoute: true
}
},
{ {
path: '/flight/approvals/new', path: '/flight/approvals/new',
component: lazy(() => import('../../views/flight/NewFlightView')), component: lazy(() => import('../../views/flight/NewFlightView')),

Loading…
Cancel
Save