Skip to content

Commit

Permalink
fix: 주석 + 불필요한 코드 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
eun-hak committed Jul 8, 2024
1 parent 81bd19d commit 4c77bef
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 72 deletions.
10 changes: 1 addition & 9 deletions public/firebase-messaging-sw.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ firebase.initializeApp({
// 푸시 내용을 처리해서 알림으로 띄운다.
self.addEventListener('push', function (event) {
if (event.data) {
// console.log(event.data.json().data);
// console.log(event.data.json().notification);

// 알림 메세지일 경우엔 event.data.json().notification;
const url = event.data.json().data;
const data = event.data.json().notification;
const options = {
Expand All @@ -44,7 +40,6 @@ self.addEventListener('notificationclick', async function (event) {
event.preventDefault();
event.notification.close();
const urlToOpen = event.notification.data.targetUrl;
// const targetId = event.notification.data.targetId;
const Type = event.notification.data.targetType;

//indexedDB틑 롱해 데이터 전달
Expand Down Expand Up @@ -83,10 +78,7 @@ self.addEventListener('notificationclick', async function (event) {
return matchingClient.focus();
} else {
if (Type === 'RESERVATION') {
return clients.openWindow(
// `reservation/myreservationlist?targetId=${event.notification.data.targetId}`
`reservation/myreservationlist`
);
return clients.openWindow(`reservation/myreservationlist`);
} else {
return clients.openWindow(`community/${event.notification.data.targetId}`);
}
Expand Down
25 changes: 0 additions & 25 deletions src/components/pwa/Fcm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,33 +12,11 @@ const firebaseConfig = {

const app = initializeApp(firebaseConfig);

/**
* FCM 토큰 발급
*/
export const setTokenHandler = async () => {
const messaging = getMessaging(app);
await getToken(messaging, {
vapidKey: process.env.NEXT_PUBLIC_VAPID_KEY
})
.then(async (currentToken) => {
if (!currentToken) {
// 토큰 생성 불가시 처리할 내용, 주로 브라우저 푸시 허용이 안된 경우에 해당한다.
} else {
// 토큰을 받았다면 여기서 DB에 저장하면 됩니다.
}
})
.catch((error) => {
console.error(error);
});
};

export const clickPushHandler = () => {
Notification.requestPermission().then((permission) => {
if (permission !== 'granted') {
// 푸시 거부됐을 때 처리할 내용
console.log('푸시 거부됨');
} else {
// 푸시 승인됐을 때 처리할 내용
console.log('푸시 승인됨');
}
});
Expand All @@ -53,11 +31,8 @@ export const getTokenHandler = async () => {
})
.then(async (currentToken) => {
if (!currentToken) {
// 토큰 생성 불가시 처리할 내용, 주로 브라우저 푸시 허용이 안된 경우에 해당한다.
console.error('토큰 생성 불가');
} else {
// 토큰을 받았다면 여기서 supabase 테이블의 저장하면 됩니다.
// console.log('currentToken', currentToken);
return currentToken;
}
})
Expand Down
3 changes: 0 additions & 3 deletions src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import ErrorBoundary from '@/components/shared/ErrorBoundary';
import Layout from '@/components/shared/Layout';
import LoadingSpinner from '@/components/shared/LoadingSpinner';
// import { AuthorizationProvider } from '@/providers/Authentication';
import MockProvider from '@/providers/MockProvider';
import QueryProvider from '@/providers/QueryProvider';
import '@/styles/globals.css';
Expand Down Expand Up @@ -41,7 +40,6 @@ export default function App({ Component, pageProps }: AppProps) {
{/* <Script
strategy="beforeInteractive"
src={`https://openapi.map.naver.com/openapi/v3/maps.js?ncpClientId=${process.env.NEXT_PUBLIC_NAVER_MAP_CLIENT_ID}`}></Script> */}
{/* <AuthorizationProvider> */}
<QueryClientProvider client={queryClient}>
<Hydrate state={pageProps.dehydratedState}>
<ErrorBoundary>
Expand All @@ -51,7 +49,6 @@ export default function App({ Component, pageProps }: AppProps) {
</Hydrate>
<ReactQueryDevtools initialIsOpen={false} />
</QueryClientProvider>
{/* </AuthorizationProvider> */}
</QueryProvider>
</MockProvider>
</Layout>
Expand Down
45 changes: 10 additions & 35 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@ import MainContainer from '@/components/shared/MainContainer';
import { useMember, useSetMember } from '@/store/user';
import React, { useEffect, useState } from 'react';
import { useQuery } from 'react-query';
// import { fcmpost } from '@/api/fcm/fcm.post.api';
// import { getTokenHandler } from '@/components/pwa/Fcm';
// import { dehydrate, useQuery, QueryClient } from 'react-query';
import PopUpModal from '@/components/home/PopUpModal';
// import { getCookie } from '@/utils/cookies';
// import { GetServerSideProps, GetServerSidePropsContext } from 'next/types';
// import { getCookie } from '@utils/cookies';
const Index = () => {
//
/* eslint-disable */
Expand All @@ -24,21 +22,6 @@ const Index = () => {
setmember(memberData?.data);
}, [memberData, setmember]);

// useEffect(() => {
// const fetchToken = async () => {
// try {
// const token = await getTokenHandler();
// if (typeof token === 'string') {
// fcmpost({ fcmToken: token });
// }
// } catch (error) {
// console.error('Failed to get FCM token:', error);
// }
// };

// fetchToken();
// }, []);

useEffect(() => {
const timeClicked = localStorage.getItem('timeClicked');
if (timeClicked) {
Expand All @@ -60,24 +43,16 @@ const Index = () => {
);
};

// export const getServerSideProps: GetServerSideProps = async (
// context: GetServerSidePropsContext
// ) => {
// // 로그인 상태를 확인하는 로직 (예: 쿠키, 로컬 스토리지, 외부 API 확인 등)
// const token = getCookie('token');
// const isLoggedIn = token;
// export const getServerSideProps = async () => {
// const token = getCookie('token') as string;

// const queryClient = new QueryClient(); // 1. 새 QueryClient 인스턴스 만들기

// // 로그인되지 않았다면 로그인 페이지로 리다이렉트
// if (!isLoggedIn) {
// return {
// redirect: {
// destination: '/sign', // 리다이렉트할 경로
// permanent: false // 이 리다이렉트가 영구적인지 여부
// }
// };
// }
// await queryClient.prefetchQuery(['userinfo'], userinfo); // 2. 데이터를 prefetch(캐싱)
// return {
// props: {} // 필요한 props
// props: {
// dehydratedState: dehydrate(queryClient) // 3. dehydrate한 캐시를 props로 페이지에 넘겨준다.
// }
// };
// };

Expand Down

0 comments on commit 4c77bef

Please sign in to comment.