-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(my-page): my-page suspense 적용 및 root page server component로 변경 #392
Draft
chaaerim
wants to merge
8
commits into
release/routing
Choose a base branch
from
refactor/my-page
base: release/routing
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
847d77e
:sparkles: feat: toast component parallel route 적용
chaaerim 60c24f7
:sparkles: feat: userInfo component parallel route로 변경
chaaerim 10f419e
:sparkles: feat: layout shifting 방지
chaaerim 9678cd3
:sparkles: feat: suspense 이용하여 userInfo skeleton 처리
chaaerim 7003a05
:sparkles: feat: ssr 고려하여 window undefined 분기 처리
chaaerim 8dc3104
:sparkles: feat: server render시 userInfo null인 경우 처리
chaaerim 51c84e8
:sparkles: feat: GoogleFormButton 분리 및 mypage 서버컴포넌트로 변경
chaaerim a6e239b
:bug: fix: import 에러 수정
chaaerim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import { Appbar } from './_components/Appbar'; | ||
import { CategoryBottomSheet } from './toks-main/_components/CategoryBottomSheet'; | ||
|
||
export default function AppBarLayout({ children }: StrictPropsWithChildren) { | ||
return ( | ||
<> | ||
<Appbar /> | ||
{children} | ||
<CategoryBottomSheet /> | ||
{/* TODO: 에러 고치기 .. */} | ||
{/* <CategoryBottomSheet /> */} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
'use client'; | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
|
||
import { useToast } from '@/common'; | ||
import { Toast as ToastComponent, ToastProps } from '@/common/components/Toast'; | ||
|
||
const Toast = () => { | ||
const { getSavedToastInfo, clearSavedToast } = useToast(); | ||
const [toastData, setToastData] = useState<ToastProps | null>(null); | ||
|
||
useEffect(() => { | ||
setToastData(getSavedToastInfo()); | ||
|
||
clearSavedToast(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
if (toastData === null) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<ToastComponent | ||
isShow={toastData.isShow} | ||
type={toastData.type} | ||
direction={toastData.direction} | ||
title={toastData.title} | ||
/> | ||
); | ||
}; | ||
|
||
export default Toast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
'use client'; | ||
|
||
import { getCookie } from 'cookies-next'; | ||
import Image from 'next/image'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { ICON_URL } from '@/common'; | ||
import { Text } from '@/common/components/Text'; | ||
|
||
import { SkeletonUserInfo } from '../_components/SkeletonUserInfo.tsx'; | ||
import { useSuspenseUserInfoQuery } from '../_lib/hooks/useSuspenseUserInfoQuery'; | ||
|
||
const UserInfo = () => { | ||
const router = useRouter(); | ||
const accessToken = getCookie('accessToken'); | ||
const { data: userInfo } = useSuspenseUserInfoQuery(accessToken as string); | ||
|
||
if (!userInfo) { | ||
return <SkeletonUserInfo />; | ||
} | ||
return ( | ||
<div className="w-full flex-col items-center pt-20px text-center"> | ||
<div className="mx-auto mb-24px h-96px w-96px overflow-hidden rounded-full"> | ||
<Image | ||
src={userInfo ? userInfo.profileImageUrl : ICON_URL.EMOJI_BASE_GRAY} | ||
alt="프로필 이미지" | ||
width={96} | ||
height={96} | ||
/> | ||
</div> | ||
<div className="mb-8px flex h-24px w-full justify-center"> | ||
<Text typo="headingL" color="gray10"> | ||
{userInfo?.nickname} | ||
</Text> | ||
<Image | ||
className="ml-4px" | ||
src={ICON_URL.CHEVRON_RIGHT} | ||
alt="닉네임 수정 버튼" | ||
width={24} | ||
height={24} | ||
onClick={() => router.push('/nickname/update')} | ||
/> | ||
</div> | ||
<div className="h-24px"> | ||
<Text typo="body" color="gray40"> | ||
{userInfo?.email} | ||
</Text> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default UserInfo; |
23 changes: 23 additions & 0 deletions
23
src/app/(BackHeader)/my-page/_components/GoogleFormButton/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use client'; | ||
import { useRouter } from 'next/navigation'; | ||
|
||
import { GOOGLE_FORM_URL } from '@/common'; | ||
import { Button } from '@/common/components/Button'; | ||
|
||
export const GoogleFormButton = () => { | ||
const router = useRouter(); | ||
|
||
return ( | ||
<Button | ||
className="w-full" | ||
size="L" | ||
typo="subheadingBold" | ||
backgroundColor="primaryDefault" | ||
onClick={() => { | ||
router.push(GOOGLE_FORM_URL); | ||
}} | ||
> | ||
이런 퀴즈가 있었으면 좋겠어요 | ||
</Button> | ||
); | ||
}; |
23 changes: 23 additions & 0 deletions
23
src/app/(BackHeader)/my-page/_components/SkeletonUserInfo.tsx/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import Image from 'next/image'; | ||
|
||
import { ICON_URL } from '@/common'; | ||
import { Skeleton } from '@/common/components/Skeleton'; | ||
|
||
export const SkeletonUserInfo = () => { | ||
return ( | ||
<div className="flex w-full animate-pulse flex-col items-center pt-20px text-center"> | ||
<div className="mx-auto mb-24px h-96px w-96px overflow-hidden rounded-full"> | ||
<Image | ||
src={ICON_URL.EMOJI_BASE_GRAY} | ||
alt="프로필 이미지" | ||
width={96} | ||
height={96} | ||
/> | ||
</div> | ||
<div className="flex w-full flex-col items-center"> | ||
<Skeleton className="mb-[8px] h-[24px] w-[120px]" /> | ||
<Skeleton className="m-[4px] h-[16px] w-[200px]" /> | ||
</div> | ||
</div> | ||
); | ||
}; |
45 changes: 0 additions & 45 deletions
45
src/app/(BackHeader)/my-page/_components/UserInfo/index.tsx
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/app/(BackHeader)/my-page/_lib/hooks/useSuspenseUserInfoQuery.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { getUserInfo } from '@/common'; | ||
|
||
export const useSuspenseUserInfoQuery = (accessToken?: string) => { | ||
return useSuspenseQuery({ | ||
queryKey: ['userInfo', accessToken], | ||
queryFn: getUserInfo, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React, { PropsWithChildren, Suspense } from 'react'; | ||
|
||
import { SkeletonUserInfo } from './_components/SkeletonUserInfo.tsx'; | ||
|
||
type Props = { | ||
toast: React.ReactNode; | ||
userInfo: React.ReactNode; | ||
}; | ||
|
||
export default function MyPageLayout({ | ||
children, | ||
toast, | ||
userInfo, | ||
}: PropsWithChildren<Props>) { | ||
return ( | ||
<> | ||
<Suspense fallback={<SkeletonUserInfo />}>{userInfo}</Suspense> | ||
{children} | ||
{toast} | ||
</> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
redirectToLoginPage함수가 혹시나 서버 컴포넌트에서 호출될까 염려하여 얼리리턴 해준건가요?
ssr대응이라는게 어떤 문제가 있어서 추가하게 되었는지 궁금합니다..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아 실행 시켜보니 window를 참조하는 과정에서 에러가 발생하는군요
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dengoyoon 네네 맞아요!! 서버에서 렌더 될 때에는 window 참조를 못해서 서버 렌더되는 경우 아예 리턴 시켜서 에러 발생을 막기 위한 코드였습니다