From a571488d92ca758a0fc3abd6868feafcfeacea77 Mon Sep 17 00:00:00 2001 From: eunhak Date: Tue, 11 Jun 2024 23:37:28 +0900 Subject: [PATCH] fix: test fix --- package-lock.json | 8 ++++++++ package.json | 2 ++ public/firebase-messaging-sw.js | 5 +---- src/api/instance.ts | 5 +++-- src/components/modal/logoutModal/index.tsx | 2 ++ .../myReservationList/modal/MeetingDetailModal.tsx | 6 +++--- src/components/reservation/remote/myreservation.ts | 2 ++ src/hook/useLoggedOut.ts | 2 +- src/hook/useLogin.ts | 5 ++++- src/pages/mypage/index.tsx | 2 ++ src/pages/mypage/question/index.tsx | 3 ++- 11 files changed, 30 insertions(+), 12 deletions(-) diff --git a/package-lock.json b/package-lock.json index faf8004..8e61d8f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "framer-motion": "^11.1.9", "haversine": "^1.1.1", "idb": "^8.0.0", + "lodash": "^4.17.21", "next": "14.2.3", "next-pwa": "^5.6.0", "react": "^18", @@ -36,6 +37,7 @@ }, "devDependencies": { "@tailwindcss/typography": "^0.5.13", + "@types/lodash": "^4.17.5", "@types/navermaps": "^3.7.5", "@types/node": "^20", "@types/react": "^18", @@ -3400,6 +3402,12 @@ "@types/node": "*" } }, + "node_modules/@types/lodash": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-MBIOHVZqVqgfro1euRDWX7OO0fBVUUMrN6Pwm8LQsz8cWhEpihlvR70ENj3f40j58TNxZaWv2ndSkInykNBBJw==", + "dev": true + }, "node_modules/@types/long": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/@types/long/-/long-4.0.2.tgz", diff --git a/package.json b/package.json index d0e9c0b..89fcb72 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "framer-motion": "^11.1.9", "haversine": "^1.1.1", "idb": "^8.0.0", + "lodash": "^4.17.21", "next": "14.2.3", "next-pwa": "^5.6.0", "react": "^18", @@ -37,6 +38,7 @@ }, "devDependencies": { "@tailwindcss/typography": "^0.5.13", + "@types/lodash": "^4.17.5", "@types/navermaps": "^3.7.5", "@types/node": "^20", "@types/react": "^18", diff --git a/public/firebase-messaging-sw.js b/public/firebase-messaging-sw.js index 2f7748c..140b22d 100644 --- a/public/firebase-messaging-sw.js +++ b/public/firebase-messaging-sw.js @@ -60,10 +60,7 @@ self.addEventListener('notificationclick', async function (event) { tx.store.put(val, key); await tx.done; } - event.waitUntil( - // 'targetId'라는 키로 event.notification.data.targetId 값을 저장합니다. - set('targetId', event.notification.data.targetId) - ); + event.waitUntil(set('targetId', event.notification.data.targetId)); // 클라이언트에 해당 사이트가 열려 있는지 체크 const promiseChain = clients diff --git a/src/api/instance.ts b/src/api/instance.ts index df3b611..3f95e7c 100644 --- a/src/api/instance.ts +++ b/src/api/instance.ts @@ -10,7 +10,7 @@ import logOnDev from '@utils/logOnDev'; // import jwtDecode from 'jwt-decode'; import { updateRefresh } from './refresh/tokenRefresh.api'; -import { UseRouter } from '@/hook/UseRouter'; +// import { UseRouter } from '@/hook/UseRouter'; export const instance: Axios = axios.create({ baseURL: process.env.NEXT_PUBLIC_BASE_URL, @@ -75,7 +75,8 @@ instance.interceptors.response.use( } } catch (refreshError) { removeCookie('refreshToken'); - UseRouter(''); + + // window.location.href = '/'; return Promise.reject(refreshError); } } else { diff --git a/src/components/modal/logoutModal/index.tsx b/src/components/modal/logoutModal/index.tsx index 5405252..f42f730 100644 --- a/src/components/modal/logoutModal/index.tsx +++ b/src/components/modal/logoutModal/index.tsx @@ -1,5 +1,6 @@ // components/LogoutModal.tsx import { useSetMember } from '@/store/user'; +import { removeCookie } from '@/utils/cookies'; import React from 'react'; interface LogoutModalProps { @@ -25,6 +26,7 @@ const LogoutModal = ({ onConfirm, onCancel }: LogoutModalProps) => { className="h-[42px] flex-1 text-center font-bold text-indigo-700 leading-normal text-lg font-['Pretendard']" onClick={() => { onConfirm(); + removeCookie('token'); setmember({ memberEmail: '', memberName: '', diff --git a/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx b/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx index b2e0af7..60cdf2e 100644 --- a/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx +++ b/src/components/reservation/myReservationList/modal/MeetingDetailModal.tsx @@ -43,9 +43,9 @@ const MeetingDetailModal = () => { // } // }, [data]); - // if (data == undefined) { - // return null; - // } + if (data == undefined) { + return null; + } const date = data && data.startAt diff --git a/src/components/reservation/remote/myreservation.ts b/src/components/reservation/remote/myreservation.ts index 720bcc6..63b86bc 100644 --- a/src/components/reservation/remote/myreservation.ts +++ b/src/components/reservation/remote/myreservation.ts @@ -40,6 +40,8 @@ export const getReservationDetail = async (reservationId: number | null) => { const { data } = await getRequest(`reservations/${reservationId}`); return data as reservationDetailData; } catch (error: any) { + alert('이미 종료된 일정입니다'); + window.location.href = '/'; return error.response.data; } }; diff --git a/src/hook/useLoggedOut.ts b/src/hook/useLoggedOut.ts index a4b62ce..5b88bf1 100644 --- a/src/hook/useLoggedOut.ts +++ b/src/hook/useLoggedOut.ts @@ -7,8 +7,8 @@ function useLoggedOut() { const query = useQueryClient(); const logout = (redirectPath = '/sign') => { - router.push(redirectPath); removeCookie('token'); + router.push(redirectPath); query.clear(); }; diff --git a/src/hook/useLogin.ts b/src/hook/useLogin.ts index e3441a7..468813b 100644 --- a/src/hook/useLogin.ts +++ b/src/hook/useLogin.ts @@ -4,6 +4,7 @@ import { setCookie } from '@/utils/cookies'; import { useRouter } from 'next/navigation'; import { useMutation } from '@tanstack/react-query'; import { useState } from 'react'; +import { throttle } from 'lodash'; //todo 기범님 오류 // import { getTokenHandler } from '@/components/pwa/Fcm'; // import { fcmpost } from '@/api/fcm/fcm.post.api'; @@ -26,11 +27,13 @@ const useLogin = () => { console.log(error); }; - const { mutate } = useMutation({ + const { mutate: originalMutate } = useMutation({ mutationFn: signin, onSuccess, onError }); + + const mutate = throttle(originalMutate, 3000); // 3초 동안 throttle 처리 return { mutate, error }; }; diff --git a/src/pages/mypage/index.tsx b/src/pages/mypage/index.tsx index cbd0c04..d024deb 100644 --- a/src/pages/mypage/index.tsx +++ b/src/pages/mypage/index.tsx @@ -18,10 +18,12 @@ const MyPage = () => { console.log('Logged out'); setModalVisible(false); setSuccessModal(true); + setTimeout(() => { logout(); }, 2000); }; + useUpdateMember(); const handleCancel = () => { setModalVisible(false); diff --git a/src/pages/mypage/question/index.tsx b/src/pages/mypage/question/index.tsx index 297ee51..9b77c4c 100644 --- a/src/pages/mypage/question/index.tsx +++ b/src/pages/mypage/question/index.tsx @@ -34,6 +34,7 @@ const InquiryForm = () => { setTitle(''); setContent(''); alert('문의등록이 완료되었습니다!'); + window.location.reload(); } catch { alert('문의등록에 실패했습니다.'); } @@ -43,7 +44,7 @@ const InquiryForm = () => { return (
map {/* api */}