Skip to content

Commit

Permalink
[Fix/#203] 웹파트 내부 QA 3차 수정 (#204)
Browse files Browse the repository at this point in the history
* fix: qa 반영

* fix: SelectedStoreModal 스타일 수정

* refactor: 로그인 안하고 찜버튼 클릭시 처리
  • Loading branch information
thisishwarang authored Jan 23, 2025
1 parent 0b3cb38 commit 393a005
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 16 deletions.
5 changes: 4 additions & 1 deletion src/apis/auth/useDeleteLogout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMutation } from '@tanstack/react-query';
import { useMutation, useQueryClient } from '@tanstack/react-query';

import { instance } from '@apis/instance';

Expand All @@ -17,10 +17,13 @@ const deleteLogout = async () => {
};

export const useDeleteLogout = () => {
const queryClient = useQueryClient();
const { goHomePage } = useEasyNavigate();

return useMutation({
mutationFn: deleteLogout,
onSuccess: () => {
queryClient.clear();
removeUser();
goHomePage();
},
Expand Down
26 changes: 16 additions & 10 deletions src/apis/myPage/useFetchUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,24 @@ import { instance } from '@apis/instance';

import { END_POINT, queryKey } from '@constants';

import { ApiResponseType, UserResponse } from '@types';
import { ApiResponseType, ErrorResponse, UserResponse } from '@types';

const fetchUser = async (): Promise<UserResponse> => {
const response = await instance.get<ApiResponseType<UserResponse>>(
END_POINT.FETCH_USER
);
if (!response.data)
return {
userName: '',
userEmail: '',
};
return response.data.data;
try {
const response = await instance.get<ApiResponseType<UserResponse>>(
END_POINT.FETCH_USER
);
return response.data.data;
} catch (error) {
const errorResponse = error as ErrorResponse;
if (errorResponse.response.status === 401) {
return {
userName: '',
userEmail: '',
};
}
throw error;
}
};

export const useFetchUser = () => {
Expand Down
17 changes: 14 additions & 3 deletions src/pages/view/components/KakaoMap/KakaoMap.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { useEffect } from 'react';
import { Map, MapMarker } from 'react-kakao-maps-sdk';

import { Modal } from '@components';
import { AuthModal, Modal } from '@components';
import { MyLocation } from '@constants';
import { useBottomSheet } from '@hooks';
import { useBottomSheet, useModal } from '@hooks';
import { useMapLoader } from '@pages/view/hooks';
import { useKakaoMap } from '@pages/view/hooks/useKakaoMap';
import { getMarkerIcon } from '@utils';
Expand All @@ -29,6 +29,7 @@ interface KakaoMapProps {
const KakaoMap = ({ currentLocation }: KakaoMapProps) => {
useMapLoader();
const { animateState, handleAnimateChange } = useBottomSheet();
const { isModalOpen, openModal, closeModal } = useModal();
const {
selectedStoreId,
storeMarkerList,
Expand All @@ -42,7 +43,7 @@ const KakaoMap = ({ currentLocation }: KakaoMapProps) => {
handleSaveButtonClick,
handleMarkerClick,
handleMapClick,
} = useKakaoMap(currentLocation, handleAnimateChange);
} = useKakaoMap(currentLocation, handleAnimateChange, openModal);

useEffect(() => {
if (selectedStoreId !== 0) {
Expand Down Expand Up @@ -116,6 +117,16 @@ const KakaoMap = ({ currentLocation }: KakaoMapProps) => {
<SelectedStoreModal storeId={selectedStoreId} />
</Modal>
)}
{isModalOpen && (
<Modal variant="center" hasBackdrop backdropClick={closeModal}>
<AuthModal
modalText="로그인이 필요한 기능이에요!"
closeButtonText="닫기"
authActionButtonText="로그인 하러가기"
onClose={closeModal}
/>
</Modal>
)}
</>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const addressWrapper = style([
export const addressStyle = style([
vars.fonts.body07_r_14,
{
height: '3.4rem',
color: vars.colors.gray600,
display: '-webkit-box',
overflow: 'hidden',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const SelectedStoreModal = ({ storeId }: SelectedStoreModalProps) => {
/>
</div>
<div className={addressWrapper}>
<p className={addressStyle}>{storeData.address}</p>
<div className={addressStyle}>{storeData.address}</div>
<Label text={storeData.station} />
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion src/pages/view/hooks/useKakaoMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
useFetchStoreCoordinateList,
} from '@apis/view';

import { isLoggedIn } from '@utils';

import { useDebounce } from './useDebounce';

import { BottomSheetState, StationType, StoreCoordinate } from '@types';
Expand All @@ -14,7 +16,8 @@ const DEFAULT_CENTER = { lat: 37.556621, lng: 126.923877 };

export const useKakaoMap = (
currentLocation: StationType,
handleAnimateChange: (animate: BottomSheetState) => void
handleAnimateChange: (animate: BottomSheetState) => void,
openModal: () => void
) => {
const { data: storeCoordinateList } = useFetchStoreCoordinateList(
currentLocation.stationEnName
Expand Down Expand Up @@ -88,6 +91,10 @@ export const useKakaoMap = (
};

const handleSaveButtonClick = () => {
if (!isLoggedIn()) {
openModal();
return;
}
setIsSaveActive((prev) => !prev);

const markerList =
Expand Down

0 comments on commit 393a005

Please sign in to comment.