('');
+ const { routerTo } = useRouter();
+ const { major } = useMajor();
+
+ const routerToGraduationRequired = () => {
+ window.location.href = graduationLink;
+ };
+
+ useEffect(() => {
+ if (!major) return;
+ const getGraduationLink = async () => {
+ const response = await http.get(`/api/graduation?major=${major}`);
+ setGraduationLink(response.data.graduationLink);
+ };
+ getGraduationLink();
+ }, [major]);
+
return (
<>
{
justify-content: center;
`}
>
-
-
+ routerTo('/announcement')}
+ />
+ routerToGraduationRequired()}
+ />
>
);
diff --git a/src/pages/Map/MapLevelObserver.tsx b/src/pages/Map/MapLevelObserver.tsx
index 1755e936..5b7b1f35 100644
--- a/src/pages/Map/MapLevelObserver.tsx
+++ b/src/pages/Map/MapLevelObserver.tsx
@@ -1,6 +1,8 @@
-import MapLevetLimitModal from '@components/Modal/MapLevelLimitModal';
+import AlertModal from '@components/Modal/AlertModal';
+import { MODAL_MESSAGE } from '@constants/modal-messages';
import { PKNU_MAP_LIMIT } from '@constants/pknu-map';
-import React, { useEffect, useState } from 'react';
+import useModals from '@hooks/useModals';
+import React, { useEffect } from 'react';
interface MapLevelObserverProps {
map: any;
@@ -12,8 +14,7 @@ const MapLevelObserver = ({ map, centerLocation }: MapLevelObserverProps) => {
return null;
}
- const [isModalOpen, setIsModalOpen] = useState(false);
-
+ const { openModal, closeModal } = useModals();
useEffect(() => {
const levelLimitHandler = () => {
if (map.getLevel() <= PKNU_MAP_LIMIT.LEVEL) {
@@ -21,18 +22,23 @@ const MapLevelObserver = ({ map, centerLocation }: MapLevelObserverProps) => {
}
map.setLevel(PKNU_MAP_LIMIT.LEVEL);
map.setCenter(centerLocation);
- setIsModalOpen((prev) => !prev);
+ openModal(AlertModal, {
+ message: MODAL_MESSAGE.ALERT.OVER_MAP_LEVEL,
+ buttonMessage: '닫기',
+ onClose: () => closeModal(AlertModal),
+ });
};
window.kakao.maps.event.addListener(map, 'zoom_changed', levelLimitHandler);
+ return () => {
+ window.kakao.maps.event.removeListener(
+ map,
+ 'zoom_changed',
+ levelLimitHandler,
+ );
+ };
});
- return (
- <>
- {isModalOpen && (
- setIsModalOpen((prev) => !prev)} />
- )}
- >
- );
+ return <>>;
};
export default MapLevelObserver;
diff --git a/src/pages/Map/MapboundaryObserver.tsx b/src/pages/Map/MapboundaryObserver.tsx
index 441255ac..f7c9ec5a 100644
--- a/src/pages/Map/MapboundaryObserver.tsx
+++ b/src/pages/Map/MapboundaryObserver.tsx
@@ -1,6 +1,8 @@
-import MapBoundsLimitModal from '@components/Modal/MapBoundsLimitModal';
+import AlertModal from '@components/Modal/AlertModal';
+import { MODAL_MESSAGE } from '@constants/modal-messages';
import { PKNU_MAP_LIMIT } from '@constants/pknu-map';
-import React, { useEffect, useState } from 'react';
+import useModals from '@hooks/useModals';
+import React, { useEffect } from 'react';
interface MapBounds {
map: any;
@@ -12,7 +14,7 @@ const MapboundaryObserver = ({ map, centerLocation }: MapBounds) => {
return null;
}
- const [isModalOpen, setIsModalOpen] = useState(false);
+ const { openModal, closeModal } = useModals();
useEffect(() => {
const boundayLimitHandler = () => {
const { La, Ma } = map.getCenter();
@@ -22,9 +24,13 @@ const MapboundaryObserver = ({ map, centerLocation }: MapBounds) => {
Ma <= PKNU_MAP_LIMIT.BOTTOM ||
La <= PKNU_MAP_LIMIT.LEFT
) {
- setIsModalOpen((prev) => !prev);
map.setLevel(4);
map.setCenter(centerLocation);
+ openModal(AlertModal, {
+ message: MODAL_MESSAGE.ALERT.OVER_MAP_LEVEL,
+ buttonMessage: '닫기',
+ onClose: () => closeModal(AlertModal),
+ });
}
};
window.kakao.maps.event.addListener(map, 'dragend', boundayLimitHandler);
@@ -38,13 +44,7 @@ const MapboundaryObserver = ({ map, centerLocation }: MapBounds) => {
};
}, []);
- return (
- <>
- {isModalOpen && (
- setIsModalOpen((prev) => !prev)} />
- )}
- >
- );
+ return <>>;
};
export default MapboundaryObserver;