From 594ac975251baf7356d1a32ece1f6b91ca359211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?scnoh=28=EB=85=B8=EC=8A=B9=EC=B2=A0=29?= Date: Thu, 15 Sep 2022 16:32:48 +0900 Subject: [PATCH] =?UTF-8?q?=EB=B9=84=EC=A0=95=EC=83=81=20=EC=95=8C?= =?UTF-8?q?=EB=A6=BC=20=EC=B5=9C=EC=B4=88=201=EB=B2=88=20=ED=91=9C?= =?UTF-8?q?=EC=B6=9C=20=EC=9E=91=EC=97=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/map/naver/dron/DronToast.js | 44 +++++++++++++--------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/src/components/map/naver/dron/DronToast.js b/src/components/map/naver/dron/DronToast.js index 1c99768..76e1fc1 100644 --- a/src/components/map/naver/dron/DronToast.js +++ b/src/components/map/naver/dron/DronToast.js @@ -11,27 +11,37 @@ const DronToast = () => { const dispatch = useDispatch(); const { controlGpList } = useSelector(state => state.controlGpState); + const [toastId, setToastId] = useState(); useEffect(() => { if (controlGpList) { - controlGpList.forEach(gps => { - if (gps.controlWarnCd && gps.controlWarnNotyCd) { - toast.info( - toastRender( - `${gps.objectId} 비정상 상황 알림`, - '경로 상에 비행 구역을 이탈했습니다.' - ), - { - autoClose: 3000, - hideProgressBar: true, - position: toast.POSITION.BOTTOM_RIGHT, - onClick: props => { - handleNotiClick(gps.controlId, gps.objectId); + if (!toastId) { + controlGpList.forEach(gps => { + // console.log("===================================") + // console.log("Warn ==> ", gps.controlWarnCd); + // console.log("Noti ==> ", gps.controlWarnNotyCd); + if (gps.controlWarnCd && gps.controlWarnNotyCd) { + + const id = toast.info( + toastRender( + `${gps.objectId} 비정상 상황 알림`, + `경로 상에 비행 구역을 이탈했습니다.` + ), + { + autoClose: false, + hideProgressBar: true, + position: toast.POSITION.BOTTOM_RIGHT, + onClick: props => { + setToastId(null); + handleNotiClick(gps.controlId, gps.objectId); + } } - } - ) - } - }) + ) + + setToastId(id); + } + }) + } } }, [controlGpList]);