Skip to content

Commit 17c1f7d

Browse files
doongeonAhranah
andauthored
Feat: 북마크 기능 추가 (#33)
* test: 테스크 로그 코드 삭제 * feat: 추천 주택 UI 구현 * Add files via upload * Create frontend-ci-cd.yml * Delete workflows directory * Update frontend-ci-cd.yml * Create deploy.yml * Update frontend-ci-cd.yml * Update frontend-ci-cd.yml * feat: 자가진단 지원 가능 유형에 맞는 공고 목록 ui 구현 * feat: 추전 주택 정보가 지도에 표시되도록 확장 * feat: 지원가능 목록에도 필터링 적용 * refactor: 좌우 스크롤 목록 ui를 분리 * feat: 북마크 로직, ui 구현 * design: 카카오맵 커스텀 오버레이 ui에 북마크 삭제, 너비 수정 * feat: 수평 카드 스크롤러에 값이 없을때 기본 레이아웃 emptyConfig 설정 * test: 테스트 코드 삭제 * remove: 더미 파일 삭제 * feat: 마이페이지에 북마크 한 공고 목록 구현 --------- Co-authored-by: HyeIn Jeong <150007915+Ahranah@users.noreply.github.com>
1 parent 1fd32a6 commit 17c1f7d

File tree

11 files changed

+1827
-669
lines changed

11 files changed

+1827
-669
lines changed

src/api/bookmardApi.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
// api/bookmarkService.js
2+
import axios from 'axios';
3+
4+
const BOOKMARK_API_URL = '/api/api/bookmark';
5+
6+
// 즐겨찾기 목록 조회
7+
export const getBookmarks = async (token) => {
8+
try {
9+
const response = await axios.get(BOOKMARK_API_URL, {
10+
headers: { Authorization: `Bearer ${token}` },
11+
});
12+
return response.data;
13+
} catch (error) {
14+
console.error('즐겨찾기 목록 조회 실패:', error);
15+
throw error;
16+
}
17+
};
18+
19+
// 즐겨찾기 추가
20+
export const addBookmark = async (bookmarkData, token) => {
21+
try {
22+
const response = await axios.post(BOOKMARK_API_URL, bookmarkData, {
23+
headers: { Authorization: `Bearer ${token}` },
24+
});
25+
return response.data;
26+
} catch (error) {
27+
console.error('즐겨찾기 추가 실패:', error);
28+
throw error;
29+
}
30+
};
31+
32+
// 즐겨찾기 삭제
33+
export const removeBookmark = async (bookmarkData, token) => {
34+
try {
35+
const response = await axios.delete(BOOKMARK_API_URL, {
36+
data: bookmarkData,
37+
headers: { Authorization: `Bearer ${token}` },
38+
});
39+
return response.data;
40+
} catch (error) {
41+
console.error('즐겨찾기 삭제 실패:', error);
42+
throw error;
43+
}
44+
};
45+
46+
// 즐겨찾기 토글 (추가/삭제 자동 판별)
47+
export const toggleBookmark = async (
48+
danziId,
49+
userId,
50+
token,
51+
currentFavorites
52+
) => {
53+
const bookmarkData = { userId, danziId };
54+
const isCurrentlyFavorited = currentFavorites.some(
55+
(fav) => fav.danziId === danziId
56+
);
57+
58+
try {
59+
if (isCurrentlyFavorited) {
60+
return await removeBookmark(bookmarkData, token);
61+
} else {
62+
return await addBookmark(bookmarkData, token);
63+
}
64+
} catch (error) {
65+
console.error('즐겨찾기 토글 실패:', error);
66+
throw error;
67+
}
68+
};

src/components/KakaoMapViewer.vue

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ const placesSearchCB = (data, status, pagination) => {
7373
if (status === window.kakao.maps.services.Status.OK) {
7474
displayPlaces(data);
7575
} else if (status === window.kakao.maps.services.Status.ZERO_RESULT) {
76-
console.warn('검색 결과가 없습니다.');
76+
// console.warn('검색 결과가 없습니다.');
7777
} else if (status === window.kakao.maps.services.Status.ERROR) {
78-
console.error('장소 검색 중 오류가 발생했습니다.');
78+
// console.error('장소 검색 중 오류가 발생했습니다.');
7979
}
8080
};
8181
@@ -119,8 +119,6 @@ const displayPlaces = (placesData) => {
119119
watch(
120120
() => props.houses,
121121
(newHouses) => {
122-
console.log(' ⚠️ : ', newHouses);
123-
124122
if (!map.value) return;
125123
126124
if (newHouses.length > 0) {
@@ -151,8 +149,6 @@ const loadAllComplexes = async () => {
151149
await geocodeComplex(house, bounds);
152150
}
153151
154-
console.log(' ⚠️ : ', bounds);
155-
156152
if (markers.value.length === 1) {
157153
// 마커가 하나뿐인 경우 해당 위치로 이동하고 적절한 줌 레벨 설정
158154
const marker = markers.value[0];
@@ -254,7 +250,7 @@ const geocodeDetailedAddress = (
254250
255251
if (callback) callback(markerData);
256252
} else {
257-
console.warn(`주소 검색 실패: ${fullAddress} (${status})`);
253+
// console.warn(`주소 검색 실패: ${fullAddress} (${status})`);
258254
// 첫 번째 시도 실패 시 두 번째 시도
259255
if (attempt === 0) {
260256
geocodeDetailedAddress(house, 1, searchFacilities, callback);
@@ -298,8 +294,6 @@ const updateMapWithHouse = (house) => {
298294
existingMarker.lng
299295
);
300296
301-
console.log(' ⚠️ : ', '지도 변경');
302-
303297
map.value.setCenter(newLatLng);
304298
map.value.setLevel(5);
305299
selectedMarker.value = existingMarker;
@@ -318,7 +312,6 @@ const onLoadKakaoMap = (newMap) => {
318312
319313
// 인포윈도우 열기 (LH 단지) - 레거시
320314
const openComplexInfowindow = (marker) => {
321-
console.log('LH 단지 마커 클릭:', marker);
322315
selectedMarker.value = marker;
323316
};
324317

0 commit comments

Comments
 (0)