Skip to content

Commit

Permalink
Merge pull request #199 from TripInfoWeb/dev_gathering
Browse files Browse the repository at this point in the history
Dev gathering
  • Loading branch information
ssssksss authored Aug 14, 2024
2 parents 2891f22 + d48a495 commit 53d0ef1
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 70 deletions.
1 change: 1 addition & 0 deletions src/components/gathering/GatheringFilterModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ const GatheringFilterModal = ({closeModal}: IGatheringFilterModalProps) => {
{
SELECTED_SCHEDULE_DATA.map(i => (
<button
key={i.name}
className={
"rounded-lg bg-main px-[.5rem] py-[.125rem] text-white"
}
Expand Down
67 changes: 3 additions & 64 deletions src/components/gathering/GatheringKakaoMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@

import { PlaceResponse } from "@/types/GatheringDto";
import Image from "next/image";
import { useEffect, useState } from "react";
import { useFormContext } from "react-hook-form";

const GatheringKakaoMap = (placeResponse :PlaceResponse) => {
const formContext = useFormContext();
const [scriptLoaded, setScriptLoaded] = useState(false);
import { useEffect } from "react";

const GatheringKakaoMap = (placeResponse: PlaceResponse) => {

useEffect(() => {
if (
placeResponse.name == "" ||
Expand Down Expand Up @@ -36,64 +33,6 @@ const GatheringKakaoMap = (placeResponse :PlaceResponse) => {
});
}, []);

useEffect(() => {
const loadScript = () => {
return new Promise<void>((resolve, reject) => {
const existingScript = document.getElementById("kakao-maps-sdk");
if (!existingScript) {
const script = document.createElement("script");
script.src = "/api/kakao-map"; // API 라우트에서 스크립트 로드
script.id = "kakao-maps-sdk";
script.onload = () => resolve();
script.onerror = () =>
reject(
new Error("Kakao Maps 스크립트를 로드하는 데 실패했습니다."),
);
document.head.appendChild(script);
} else {
resolve(); // 이미 스크립트가 로드된 경우
}
});
};

loadScript().then(() => {
setScriptLoaded(true);
});
}, []);

useEffect(() => {

if (!scriptLoaded) return;

const placeName = placeResponse.name;
if (!placeName) return;

const lat = Number(placeResponse.yaxis);
const lng = Number(placeResponse.xaxis);

const renderMap = () => {
const container = document.getElementById("map");
if (!container) return;

const options = {
center: new window.kakao.maps.LatLng(lat, lng),
level: 3,
draggable: false, // 지도를 움직이지 못하게 설정
scrollwheel: false, // 마우스 휠로 확대/축소 불가
disableDoubleClickZoom: true, // 더블클릭으로 확대 불가
};

const map = new window.kakao.maps.Map(container, options);
const markerPosition = new window.kakao.maps.LatLng(lat,lng);
new window.kakao.maps.Marker({
position: markerPosition,
map: map,
});
};

window.kakao.maps.load(renderMap);
}, [scriptLoaded, formContext]);

return (
<article className={"flex flex-col gap-[2rem]"}>
<div
Expand Down
6 changes: 4 additions & 2 deletions src/components/gathering/GatheringSubCategoryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ const GatheringSubCategoryList = ({ gatheringCategoryList, activeGatheringCatego
<button onClick={()=>changeGatheringCategoryHandler(0)} className={
`rounded-full border-2 border-[#E9EBED] px-3 py-[0.375rem] text-sm font-medium hover:scale-105 ${activeGatheringCategoryId == 0 && "text-white bg-main"}`
}> 전체 </button>
{gatheringCategoryList.map((i, index) => (
<button onClick={()=>changeGatheringCategoryHandler(i.id)} className={
{gatheringCategoryList.map((i) => (
<button
key={i.id}
onClick={() => changeGatheringCategoryHandler(i.id)} className={
`rounded-full border-2 border-[#E9EBED] px-3 py-[0.375rem] text-sm font-medium hover:scale-105 ${activeGatheringCategoryId == i.id && "text-white bg-main"}`
}> {i.name} </button>
))}
Expand Down
1 change: 1 addition & 0 deletions src/components/gathering/modal/GatheringPlaceModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ const GatheringPlaceModal = (props: IGatheringPlaceModalProps) => {
handleAddressSearch(debouncedKeyword);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [debouncedKeyword]);

return (
Expand Down
3 changes: 2 additions & 1 deletion src/components/gathering/modal/GatheringSettingModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const GatheringSettingModal = (props: IGatheringSettingModalProps) => {
}
});
setDeadlineMinute(_minutes.length > 0 ? _minutes[0] : 0);
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
},[])


Expand Down
4 changes: 2 additions & 2 deletions src/containers/common/HeaderContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import useAuthStore from "@/store/authStore";
import { userResponseDto } from "@/types/UserDto";
import { fetchWithAuth } from "@/utils/fetchWithAuth";
import { usePathname, useRouter } from "next/navigation";
import { useEffect, useLayoutEffect, useState } from "react";
import { useEffect, useState } from "react";

const HeaderContainer = () => {
const pathname = usePathname();
Expand Down Expand Up @@ -51,7 +51,7 @@ const HeaderContainer = () => {
};
}, []);

useLayoutEffect(() => {
useEffect(() => {
// 자동 로그인
const login = async () => {
try {
Expand Down
1 change: 1 addition & 0 deletions src/containers/common/HeaderSidebarContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const HeaderSidebarContainer = ({ onClose }: Props) => {
return () => {
window.removeEventListener('resize', handleResize);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/containers/gathering/edit/GatheringEditorContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const GatheringEditorContainer = ({gatheringData}: IGatheringEditorContainer) =>
subCategoryName: "",
},
});
const params = useParams();

const updateGatheringHandler = async () => {
const params = useParams();
const { id } = params;
const { mainCategoryName, subCategoryName, mainCategoryId, allowedSex, hashtags, searchId, placeName, xAxis, yAxis, roadAddressName, subCategoryId, ...requestData } = methods.getValues();
try {
Expand Down
1 change: 1 addition & 0 deletions src/containers/gathering/write/GatheringPlaceContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const GatheringPlaceContainer = (props: IGatheringPlaceContainerProps) => {

new window.kakao.maps.StaticMap(container, options);
});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [formContext.getValues("placeName")]);

useEffect(() => {
Expand Down

0 comments on commit 53d0ef1

Please sign in to comment.