diff --git a/src/apis/core/axios.ts b/src/apis/core/axios.ts index 04ba50cd..dd46933b 100644 --- a/src/apis/core/axios.ts +++ b/src/apis/core/axios.ts @@ -5,8 +5,6 @@ import { isAuthFailedError, isAuthRefreshError, isAxiosErrorWithCustomCode, - setAxiosAuthHeader, - updateToken, } from '@/utils/helpers'; import isClient from '@/utils/isClient'; import webStorage from '@/utils/storage'; @@ -53,10 +51,7 @@ const responseHandler = async (error: unknown) => { } if (isAuthFailedError(code)) { - storage.remove(); - if (isClient()) { - history.pushState('', '', '/'); - } + removeToken(); } } else { console.error('예상하지 못한 오류가 발생했어요.\n', error); @@ -65,12 +60,45 @@ const responseHandler = async (error: unknown) => { return Promise.reject(error); }; -const silentRefresh = (originRequest: InternalAxiosRequestConfig) => { - return updateToken().then(newToken => { +const silentRefresh = async (originRequest: InternalAxiosRequestConfig) => { + try { + const newToken = await updateToken(); storage.set(newToken); setAxiosAuthHeader(originRequest, newToken); - return publicApi(originRequest); - }); + return await publicApi(originRequest); + } catch { + removeToken(); + } +}; + +const updateToken = async () => { + try { + const { + data: { accessToken }, + } = await axios.post<{ accessToken: string }>('/service-api/auth/token'); + + if (!accessToken) { + throw new Error('새로운 accessToken을 받아오지 못했어요.'); + } + + return accessToken; + } catch (error) { + return Promise.reject(error); + } +}; + +const removeToken = () => { + storage.remove(); + if (isClient()) { + history.pushState('', '', '/'); + } +}; + +const setAxiosAuthHeader = ( + config: InternalAxiosRequestConfig, + token: string +) => { + config.headers['Authorization'] = `Bearers ${token}`; }; publicApi.interceptors.request.use(requestHandler); diff --git a/src/app/book/search/page.tsx b/src/app/book/search/page.tsx index 0b649e8f..91eb837c 100644 --- a/src/app/book/search/page.tsx +++ b/src/app/book/search/page.tsx @@ -7,7 +7,7 @@ import useBookSearchQuery from '@/queries/book/useBookSearchQuery'; import useRecentSearchesQuery from '@/queries/book/useRecentSearchesQuery'; import useDebounceValue from '@/hooks/useDebounce'; -import { isAuthed } from '@/utils/helpers/auth'; +import { checkAuthentication } from '@/utils/helpers'; import TopHeader from '@/v1/base/TopHeader'; import BookSearchInput from '@/v1/bookSearch/BookSearchInput'; @@ -21,6 +21,7 @@ import BookSearchResults from '@/v1/bookSearch/SearchResult'; */ const BookSearch = () => { + const isAuthenticated = checkAuthentication(); const [inputSearchValue, setInputSearchValue] = useState(''); const queryKeyword = useDebounceValue(inputSearchValue, 1000); @@ -32,7 +33,9 @@ const BookSearch = () => { page: 1, pageSize: 12, }); - const recentSearchesInfo = useRecentSearchesQuery({ enabled: isAuthed() }); + const recentSearchesInfo = useRecentSearchesQuery({ + enabled: isAuthenticated, + }); const searchedBooks = bookSearchInfo.isSuccess ? bookSearchInfo.data.pages.flatMap(page => page.searchBookResponseList) diff --git a/src/app/bookarchive/page.tsx b/src/app/bookarchive/page.tsx index 8fc435fb..9d4d0297 100644 --- a/src/app/bookarchive/page.tsx +++ b/src/app/bookarchive/page.tsx @@ -1,7 +1,7 @@ 'use client'; import useMyProfileQuery from '@/queries/user/useMyProfileQuery'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { Suspense } from 'react'; import useMounted from '@/hooks/useMounted'; import BookArchiveForAuth from '@/v1/bookArchive/BookArchiveForAuth'; @@ -21,13 +21,14 @@ export default function BookArchivePage() { } const Contents = () => { + const isAuthenticated = checkAuthentication(); const { data: userData } = useMyProfileQuery({ - enabled: isAuthed(), + enabled: isAuthenticated, }); const mounted = useMounted(); if (!mounted) return null; - return isAuthed() ? ( + return isAuthenticated ? ( ) : ( diff --git a/src/app/bookshelf/[bookshelfId]/page.tsx b/src/app/bookshelf/[bookshelfId]/page.tsx index a9c103d2..747e5919 100644 --- a/src/app/bookshelf/[bookshelfId]/page.tsx +++ b/src/app/bookshelf/[bookshelfId]/page.tsx @@ -7,7 +7,7 @@ import useBookShelfBooksQuery from '@/queries/bookshelf/useBookShelfBookListQuer import useBookShelfInfoQuery from '@/queries/bookshelf/useBookShelfInfoQuery'; import useMutateBookshelfLikeQuery from '@/queries/bookshelf/useMutateBookshelfLikeQuery'; import useToast from '@/v1/base/Toast/useToast'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { IconKakao } from '@public/icons'; import TopNavigation from '@/v1/base/TopNavigation'; import BookShelfRow from '@/v1/bookShelf/BookShelfRow'; @@ -26,6 +26,7 @@ export default function UserBookShelfPage({ bookshelfId: APIBookshelf['bookshelfId']; }; }) { + const isAuthenticated = checkAuthentication(); const { data, isSuccess } = useBookShelfInfoQuery({ bookshelfId }); const { mutate: mutateBookshelfLike } = useMutateBookshelfLikeQuery(bookshelfId); @@ -34,7 +35,7 @@ export default function UserBookShelfPage({ if (!isSuccess) return null; const handleClickLikeButton = () => { - if (!isAuthed()) { + if (!isAuthenticated) { showToast({ message: '로그인 후 이용해주세요.', type: 'normal' }); return; } @@ -84,6 +85,7 @@ const BookShelfContent = ({ bookshelfId: APIBookshelf['bookshelfId']; userNickname: APIBookshelfInfo['userNickname']; }) => { + const isAuthenticated = checkAuthentication(); const { ref, inView } = useInView(); const { @@ -104,7 +106,7 @@ const BookShelfContent = ({ // TODO: Suspense 적용 if (!isSuccess) return null; - return isAuthed() ? ( + return isAuthenticated ? ( <> {booksData.pages.map(page => page.books.map((rowBooks, idx) => ( diff --git a/src/app/group/[groupId]/page.tsx b/src/app/group/[groupId]/page.tsx index cc0d40d5..73dd518a 100644 --- a/src/app/group/[groupId]/page.tsx +++ b/src/app/group/[groupId]/page.tsx @@ -2,7 +2,7 @@ import Link from 'next/link'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { KAKAO_LOGIN_URL } from '@/constants/url'; import SSRSafeSuspense from '@/components/SSRSafeSuspense'; @@ -17,6 +17,7 @@ const DetailBookGroupPage = ({ }: { params: { groupId: number }; }) => { + const isAuthenticated = checkAuthentication(); return ( <> @@ -35,7 +36,7 @@ const DetailBookGroupPage = ({ - {isAuthed() ? ( + {isAuthenticated ? ( ) : ( diff --git a/src/app/group/page.tsx b/src/app/group/page.tsx index 26e67e16..30b67212 100644 --- a/src/app/group/page.tsx +++ b/src/app/group/page.tsx @@ -16,11 +16,12 @@ import DetailBookGroupCard, { import useEntireGroupsQuery from '@/queries/group/useEntireGroupsQuery'; import useMyGroupsQuery from '@/queries/group/useMyGroupQuery'; import { useMyProfileId } from '@/queries/user/useMyProfileQuery'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import useMounted from '@/hooks/useMounted'; import Loading from '@/v1/base/Loading'; const GroupPage = () => { + const isAuthenticated = checkAuthentication(); const handleSearchInputClick = () => { alert('아직 준비 중인 기능이에요.'); }; @@ -31,7 +32,7 @@ const GroupPage = () => {
}> - {isAuthed() && } + {isAuthenticated && }
@@ -45,10 +46,11 @@ const GroupPage = () => { export default GroupPage; const MyBookGroupList = () => { + const isAuthenticated = checkAuthentication(); const { data: { bookGroups }, - } = useMyGroupsQuery({ enabled: isAuthed() }); - const { data: myId } = useMyProfileId({ enabled: isAuthed() }); + } = useMyGroupsQuery({ enabled: isAuthenticated }); + const { data: myId } = useMyProfileId({ enabled: isAuthenticated }); return (
diff --git a/src/app/profile/me/add/page.tsx b/src/app/profile/me/add/page.tsx index cf6532be..8cbfef82 100644 --- a/src/app/profile/me/add/page.tsx +++ b/src/app/profile/me/add/page.tsx @@ -1,25 +1,23 @@ 'use client'; -import { Suspense } from 'react'; import useAllJobQuery from '@/queries/job/useAllJobQuery'; -import { isAuthed } from '@/utils/helpers'; -import AuthRequired from '@/ui/AuthRequired'; +import { checkAuthentication } from '@/utils/helpers'; import AddJobProfile from '@/v1/profile/AddJobProfile'; +import SSRSafeSuspense from '@/components/SSRSafeSuspense'; const AddJobProfilePage = () => { return ( - - - - - + + + ); }; const Contents = () => { - const allJobQuery = useAllJobQuery({ enabled: isAuthed() }); + const isAuthenticated = checkAuthentication(); + const allJobQuery = useAllJobQuery({ enabled: isAuthenticated }); return allJobQuery.isSuccess ? ( diff --git a/src/app/profile/me/edit/page.tsx b/src/app/profile/me/edit/page.tsx index e5604c35..4016132d 100644 --- a/src/app/profile/me/edit/page.tsx +++ b/src/app/profile/me/edit/page.tsx @@ -1,13 +1,12 @@ 'use client'; -import { Suspense } from 'react'; import useAllJobQuery from '@/queries/job/useAllJobQuery'; import useMyProfileQuery from '@/queries/user/useMyProfileQuery'; -import { isAuthed } from '@/utils/helpers'; -import AuthRequired from '@/ui/AuthRequired'; +import { checkAuthentication } from '@/utils/helpers'; import EditProfile from '@/v1/profile/EditProfile'; +import SSRSafeSuspense from '@/components/SSRSafeSuspense'; /** * @todo @@ -16,16 +15,15 @@ import EditProfile from '@/v1/profile/EditProfile'; const EditProfilePage = () => { return ( - - - - - + + + ); }; const Contents = () => { - const allJobQuery = useAllJobQuery({ enabled: isAuthed() }); + const isAuthenticated = checkAuthentication(); + const allJobQuery = useAllJobQuery({ enabled: isAuthenticated }); const { data: profileData } = useMyProfileQuery(); return allJobQuery.isSuccess ? ( diff --git a/src/app/profile/me/group/page.tsx b/src/app/profile/me/group/page.tsx index d684f5d4..2ef527e2 100644 --- a/src/app/profile/me/group/page.tsx +++ b/src/app/profile/me/group/page.tsx @@ -1,7 +1,7 @@ 'use client'; import useMyGroupsQuery from '@/queries/group/useMyGroupQuery'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import BackButton from '@/v1/base/BackButton'; import TopNavigation from '@/v1/base/TopNavigation'; @@ -22,7 +22,8 @@ const UserGroupPage = () => { }; const UserGroupContent = () => { - const { data, isSuccess } = useMyGroupsQuery({ enabled: isAuthed() }); + const isAuthenticated = checkAuthentication(); + const { data, isSuccess } = useMyGroupsQuery({ enabled: isAuthenticated }); if (!isSuccess) { return ( diff --git a/src/app/profile/me/page.tsx b/src/app/profile/me/page.tsx index 7ad0e955..30e2f1b1 100644 --- a/src/app/profile/me/page.tsx +++ b/src/app/profile/me/page.tsx @@ -1,7 +1,7 @@ 'use client'; import { useRouter } from 'next/navigation'; -import { isAuthed, removeAuth } from '@/utils/helpers'; +import { checkAuthentication, removeAuth } from '@/utils/helpers'; import userAPI from '@/apis/user'; import TopHeader from '@/v1/base/TopHeader'; import ProfileInfo from '@/v1/profile/info/ProfileInfo'; @@ -19,9 +19,10 @@ const USER_ID = 'me'; const KAKAO_LOGIN_URL = `${process.env.NEXT_PUBLIC_API_URL}/oauth2/authorize/kakao?redirect_uri=${process.env.NEXT_PUBLIC_CLIENT_REDIRECT_URI}`; const MyProfilePage = () => { + const isAuthenticated = checkAuthentication(); return ( }> - {isAuthed() ? : } + {isAuthenticated ? : } ); }; diff --git a/src/ui/BookDetail/BookCommentList.tsx b/src/ui/BookDetail/BookCommentList.tsx index 1417a077..2ebe640b 100644 --- a/src/ui/BookDetail/BookCommentList.tsx +++ b/src/ui/BookDetail/BookCommentList.tsx @@ -14,7 +14,10 @@ import type { APIBookComment, APIBookmarkedUserList } from '@/types/book'; import { SERVICE_ERROR_MESSAGE } from '@/constants'; import { useToast } from '@/hooks/toast'; import LoginBottomSheet from '@/ui/LoginBottomSheet'; -import { isAuthed, isAxiosErrorWithCustomCode } from '@/utils/helpers'; +import { + checkAuthentication, + isAxiosErrorWithCustomCode, +} from '@/utils/helpers'; interface Props { bookId: number; @@ -25,6 +28,7 @@ type CommentType = 'me' | 'user'; type CommentRecordType = Record; const BookCommentList = ({ bookId, isInMyBookshelf }: Props) => { + const isAuthenticated = checkAuthentication(); const { showToast } = useToast(); const commentTextAreaRef = useRef(null); const bookCommentsQueryInfo = useBookCommentsQuery(bookId); @@ -104,7 +108,7 @@ const BookCommentList = ({ bookId, isInMyBookshelf }: Props) => { }; const handleCreateCommentDrawerOpen = () => { - if (!isAuthed()) { + if (!isAuthenticated) { onLoginBottomSheetOpen(); return; } @@ -122,7 +126,7 @@ const BookCommentList = ({ bookId, isInMyBookshelf }: Props) => { return ( - {!isAuthed() && ( + {!isAuthenticated && ( { + const isAuthenticated = checkAuthentication(); const theme = useTheme(); const [bookmark, setBookmark] = useState(bookmarkInfo.isInMyBookshelf); @@ -46,7 +47,7 @@ const BookInfo = ({ } = useDisclosure(); const handleBookmarkClick = () => { - if (!isAuthed()) { + if (!isAuthenticated) { onLoginBottomSheetOpen(); return; } @@ -106,7 +107,7 @@ const BookInfo = ({ )} - {!isAuthed() && ( + {!isAuthenticated && ( void; } const BookSearch = ({ onBookClick }: BookSearchProps) => { + const isAuthenticated = checkAuthentication(); const [inputValue, setInputValue] = useState(''); const queryKeyword = useDebounceValue(inputValue, 1000); @@ -36,7 +37,9 @@ const BookSearch = ({ onBookClick }: BookSearchProps) => { pageSize: 12, }); - const recentSearchesInfo = useRecentSearchesQuery({ enabled: isAuthed() }); + const recentSearchesInfo = useRecentSearchesQuery({ + enabled: isAuthenticated, + }); const searchedBooks = bookSearchInfo.isSuccess ? bookSearchInfo.data.pages.flatMap(page => page.searchBookResponseList) @@ -56,7 +59,7 @@ const BookSearch = ({ onBookClick }: BookSearchProps) => { if (inView && bookSearchInfo.hasNextPage) { bookSearchInfo.fetchNextPage(); } - isAuthed() && recentSearchesInfo.refetch(); + isAuthenticated && recentSearchesInfo.refetch(); }, [ bookSearchInfo.fetchNextPage, inView, @@ -64,6 +67,7 @@ const BookSearch = ({ onBookClick }: BookSearchProps) => { queryKeyword, bookSearchInfo, recentSearchesInfo, + isAuthenticated, ]); return ( diff --git a/src/ui/BottomNavigation/index.tsx b/src/ui/BottomNavigation/index.tsx index bcb7c08d..09551bc4 100644 --- a/src/ui/BottomNavigation/index.tsx +++ b/src/ui/BottomNavigation/index.tsx @@ -1,4 +1,4 @@ -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { Flex, useDisclosure } from '@chakra-ui/react'; import { usePathname } from 'next/navigation'; import { MouseEvent } from 'react'; @@ -6,6 +6,7 @@ import LoginBottomSheet from '../LoginBottomSheet'; import NavigationItem from './NavigationItem'; const BottomNavigation = () => { + const isAuthenticated = checkAuthentication(); const { isOpen, onOpen, onClose } = useDisclosure(); const pathname = usePathname(); @@ -31,7 +32,7 @@ const BottomNavigation = () => { label: '내 프로필', href: '/profile/me', onClick: (event: MouseEvent) => { - if (isAuthed()) return; + if (isAuthenticated) return; onOpen(); event.preventDefault(); }, diff --git a/src/ui/Group/GroupComment/index.tsx b/src/ui/Group/GroupComment/index.tsx index 3c5bff37..78ddac9e 100644 --- a/src/ui/Group/GroupComment/index.tsx +++ b/src/ui/Group/GroupComment/index.tsx @@ -3,7 +3,7 @@ import Link from 'next/link'; import { initialBookGroupComments } from '@/constants/initialBookGroupComments'; import { APIGroupComment } from '@/types/group'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import CommentDeleteModal from './CommentDeleteModal'; import CommentModifyModal from './CommentModifyModal'; import GuideMessage from './GuideMessage'; @@ -29,18 +29,19 @@ const CommentsList = ({ handleDeleteCommentBtnClick, handleModifyCommentBtnClick, }: commentsListProps) => { + const isAuthenticated = checkAuthentication(); const getFilteredComments = () => { const commentsLength = commentsListData.length; - if (!isAuthed() && !isPublic && commentsLength < 5) { + if (!isAuthenticated && !isPublic && commentsLength < 5) { return initialBookGroupComments.slice(0, commentsLength); - } else if (!isAuthed() && !isPublic) { + } else if (!isAuthenticated && !isPublic) { return initialBookGroupComments; } - if (isAuthed() && !isPublic && !isGroupMember && commentsLength < 5) { + if (isAuthenticated && !isPublic && !isGroupMember && commentsLength < 5) { return initialBookGroupComments.slice(0, commentsLength); - } else if (isAuthed() && !isPublic && !isGroupMember) { + } else if (isAuthenticated && !isPublic && !isGroupMember) { return initialBookGroupComments; } return commentsListData; @@ -74,8 +75,8 @@ const CommentsList = ({ diff --git a/src/ui/Group/GroupDetail/GroupInfo.tsx b/src/ui/Group/GroupDetail/GroupInfo.tsx index c70811a4..6d0caa75 100644 --- a/src/ui/Group/GroupDetail/GroupInfo.tsx +++ b/src/ui/Group/GroupDetail/GroupInfo.tsx @@ -23,7 +23,7 @@ import { useToast } from '@/hooks/toast'; import TopNavigation from '@/ui/common/TopNavigation'; import { Menu, MenuItem } from '@/ui/common/Menu'; import LoginBottomSheet from '@/ui/LoginBottomSheet'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; interface GroupInfoProps { groupInfoData: APIGroupDetail; @@ -40,6 +40,7 @@ const GroupInfo = ({ handleParticipateBtnClick, handleDeleteGroupBtnClick, }: GroupInfoProps) => { + const isAuthenticated = checkAuthentication(); const [password, setPassword] = useState(''); const cancelRef = useRef(null); const { @@ -97,7 +98,7 @@ const GroupInfo = ({ }; const onPartInButtonClick = () => { - if (!isAuthed()) { + if (!isAuthenticated) { onLoginModalOpen(); return; } diff --git a/src/ui/Group/GroupHeader.tsx b/src/ui/Group/GroupHeader.tsx index 0ea005c0..3aa89f33 100644 --- a/src/ui/Group/GroupHeader.tsx +++ b/src/ui/Group/GroupHeader.tsx @@ -2,14 +2,15 @@ import LoginBottomSheet from '@/ui/LoginBottomSheet'; import { Box, Button, Flex, Text, useDisclosure } from '@chakra-ui/react'; import Link from 'next/link'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { MouseEvent } from 'react'; const GroupHeader = () => { + const isAuthenticated = checkAuthentication(); const { isOpen, onOpen, onClose } = useDisclosure(); const onClick = (event: MouseEvent) => { - if (isAuthed()) return; + if (isAuthenticated) return; onOpen(); event.preventDefault(); }; diff --git a/src/ui/InteractiveBookShelf/index.tsx b/src/ui/InteractiveBookShelf/index.tsx index c01b00ae..0e274112 100644 --- a/src/ui/InteractiveBookShelf/index.tsx +++ b/src/ui/InteractiveBookShelf/index.tsx @@ -1,6 +1,6 @@ import { APIBook } from '@/types/book'; import InteractiveBook from '@/ui//InteractiveBook'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import { Box, Flex, SimpleGrid } from '@chakra-ui/react'; import { useCallback, useEffect, useState } from 'react'; @@ -11,6 +11,7 @@ const InteractiveBookShelf = ({ }: { books: Pick[]; }) => { + const isAuthenticated = checkAuthentication(); const [slicedBooks, setSlicedBooks] = useState< Pick[][] >([[]]); @@ -34,7 +35,7 @@ const InteractiveBookShelf = ({ {slicedBooks.map((books, idx) => ( { +const checkAuthentication = () => { const accessToken = storage.get(); return !!accessToken; }; @@ -16,4 +16,4 @@ const removeAuth = () => { storage.remove(); }; -export { isAuthed, setAuth, removeAuth }; +export { checkAuthentication, setAuth, removeAuth }; diff --git a/src/utils/helpers/axiosHandler.ts b/src/utils/helpers/axiosHandler.ts deleted file mode 100644 index d3e0c185..00000000 --- a/src/utils/helpers/axiosHandler.ts +++ /dev/null @@ -1,32 +0,0 @@ -import axios, { InternalAxiosRequestConfig } from 'axios'; - -import { ACCESS_TOKEN_STORAGE_KEY } from '@/constants'; -import webStorage from '@/utils/storage'; - -const updateToken = async () => { - const storage = webStorage(ACCESS_TOKEN_STORAGE_KEY); - - try { - const { - data: { accessToken }, - } = await axios.post<{ accessToken: string }>('/service-api/auth/token'); - - if (!accessToken) { - throw new Error('새로운 accessToken을 받아오지 못했어요.'); - } - - return accessToken; - } catch (error) { - storage.remove(); - return Promise.reject(error); - } -}; - -const setAxiosAuthHeader = ( - config: InternalAxiosRequestConfig, - token: string -) => { - config.headers['Authorization'] = `Bearers ${token}`; -}; - -export { updateToken, setAxiosAuthHeader }; diff --git a/src/utils/helpers/index.ts b/src/utils/helpers/index.ts index 915b8ade..8b794342 100644 --- a/src/utils/helpers/index.ts +++ b/src/utils/helpers/index.ts @@ -1,3 +1,2 @@ export * from './auth'; -export * from './axiosHandler'; export * from './error'; diff --git a/src/v1/comment/BookCommentList.tsx b/src/v1/comment/BookCommentList.tsx index 6d44e6d1..e48469c2 100644 --- a/src/v1/comment/BookCommentList.tsx +++ b/src/v1/comment/BookCommentList.tsx @@ -1,12 +1,13 @@ import { useMyProfileId } from '@/queries/user/useMyProfileQuery'; import { useBookComments } from '@/queries/book/useBookCommentsQuery'; -import { isAuthed } from '@/utils/helpers'; +import { checkAuthentication } from '@/utils/helpers'; import CommentList from './CommentList'; const BookCommentList = ({ bookId }: { bookId: number }) => { + const isAuthenticated = checkAuthentication(); const { data: comments } = useBookComments(bookId); - const { data: myId } = useMyProfileId({ enabled: isAuthed() }); + const { data: myId } = useMyProfileId({ enabled: isAuthenticated }); return ( { + const isAuthenticated = checkAuthentication(); const { data: bookGroupInfo } = useBookGroup(groupId); const { data: comments } = useBookGroupComments(groupId); - const { data: myId } = useMyProfileId({ enabled: isAuthed() }); + const { data: myId } = useMyProfileId({ enabled: isAuthenticated }); const { isPublic, isMember } = bookGroupInfo; const isHidden = !isPublic && !isMember;