-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#18] useQuery, useInfiniteQuery -> useSuspenseQuery, useSuspenseInfiniteQuery 교체 #19
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
f00c644
🔨 refactor: useQuery를 useSuspenseQuery로 교체 및 error 처러 코드 삭제
lee0jae330 e34558e
🔨 refactor: 로딩 UI 및 에러 처리 코드 삭제
lee0jae330 311011a
🔨 refactor: suspense 적용 및 error boundy fallback에 workspace 에러 페이지 설정
lee0jae330 512b151
🔨 refactor: useInfinityQuery -> useSuspenseQuery로 교체
lee0jae330 057d78d
🙀 chore: 400 에러와 404에러의 에러 코드 및 상태 메세지가 잘못 설정 되어 있어 올바르게 수정
lee0jae330 5b2ac98
🐛 fix: 기존 에러 발생 시 500 에러로만 응답하는 문제 해결
lee0jae330 c34bab2
🔨 refactor: workspaceContainer에서 워크스페이스 데이터를 렌더링하고 페칭하는 부분을 분리함
lee0jae330 e2776d7
🙀 chore: 컴포넌트 분리에 따른 코드 수정
lee0jae330 cce87b2
🙀 chore: github action 에서 파일명 변경을 감지하지 못한 문제로 인해 파일명 변경
lee0jae330 f704bc9
🙀 chore: 불필요한 console.log 삭제
lee0jae330 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
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
14 changes: 14 additions & 0 deletions
14
apps/client/src/pages/WorkspaceErrorPage/WorkspaceErrorPage.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,14 @@ | ||
import { ErrorPage, NotFound } from '@/pages'; | ||
|
||
import toast from 'react-hot-toast'; | ||
import { useRouteError } from 'react-router-dom'; | ||
|
||
export const WorkspaceErrorPage = () => { | ||
const error: any = useRouteError(); | ||
const statusCode = error?.response?.statusCode || error?.status; | ||
if (statusCode === 404) { | ||
toast.error('워크스페이스 정보 불러오기 실패'); | ||
return <NotFound />; | ||
} | ||
return <ErrorPage />; | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
export { HomePage } from './HomePage/HomePage'; | ||
export { NotFound } from './NotFound/NotFound'; | ||
export { WorkspacePage } from './Workspacepage/WorkspacePage'; | ||
export { ErrorPage } from './ErrorPage/ErrorPage'; | ||
export { WorkspaceErrorPage } from './WorkspaceErrorPage/WorkspaceErrorPage'; |
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 |
---|---|---|
|
@@ -3,16 +3,15 @@ import { createUserId, getUserId, removeCssClassNamePrefix } from '@/shared/util | |
import { | ||
useClassBlockStore, | ||
useCssPropsStore, | ||
useImageModalStore, | ||
useResetCssStore, | ||
useWorkspaceChangeStatusStore, | ||
useWorkspaceStore, | ||
useImageModalStore, | ||
} from '@/shared/store'; | ||
|
||
import { WorkspaceApi } from '@/shared/api'; | ||
import toast from 'react-hot-toast'; | ||
import { useEffect } from 'react'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { workspaceKeys } from '@/shared/hooks'; | ||
|
||
export const useGetWorkspace = (workspaceId: string) => { | ||
|
@@ -24,29 +23,19 @@ export const useGetWorkspace = (workspaceId: string) => { | |
const { resetChangedStatusState } = useWorkspaceChangeStatusStore(); | ||
const { setIsResetCssChecked } = useResetCssStore(); | ||
const { setInitialImageMap, setInitialImageList } = useImageModalStore(); | ||
const { data, isPending, isError } = useQuery({ | ||
const { data, isPending, isError } = useSuspenseQuery({ | ||
queryKey: workspaceKeys.detail(workspaceId), | ||
queryFn: () => { | ||
resetChangedStatusState(); | ||
return workspaceApi.getWorkspace(userId, workspaceId); | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
resetChangedStatusState(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (isError) { | ||
toast.error('워크스페이스 정보 불러오기 실패'); | ||
return; | ||
} | ||
if (!data) { | ||
if (!isError || !data || !data.workspaceDto) { | ||
return; | ||
} | ||
|
||
if (!data.workspaceDto) { | ||
return; | ||
} | ||
Comment on lines
-39
to
-49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if문 최소화 좋네요 👍 |
||
setName(data.workspaceDto.name); | ||
Object.keys(data.workspaceDto.totalCssPropertyObj).forEach((className) => { | ||
createCssClassBlock(className); | ||
|
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
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
22 changes: 22 additions & 0 deletions
22
apps/client/src/widgets/home/WorkspaceSection/WorkspaceSection.stories.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,22 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import { WorkspaceSection } from './WorkspaceSection'; | ||
|
||
const meta: Meta<typeof WorkspaceSection> = { | ||
title: 'widgets/home/WorkspaceSection', | ||
component: WorkspaceSection, | ||
parameters: { | ||
layout: 'fullscreen', | ||
}, | ||
tags: ['autodocs'], | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof WorkspaceSection>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
// propsname: value, | ||
}, | ||
}; |
20 changes: 20 additions & 0 deletions
20
apps/client/src/widgets/home/WorkspaceSection/WorkspaceSection.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,20 @@ | ||
import { WorkspaceContainer, WorkspaceHeader } from '@/widgets'; | ||
|
||
import { SkeletonWorkspaceList } from '@/shared/ui'; | ||
import { Suspense } from 'react'; | ||
|
||
/** | ||
* | ||
* @description | ||
* 워크스페이스 헤더와 컨테이너를 합친 섹션 컴포넌트 | ||
*/ | ||
export const WorkspaceSection = () => { | ||
return ( | ||
<section className="w-full max-w-[1152px] px-3 pb-48"> | ||
<WorkspaceHeader /> | ||
<Suspense fallback={<SkeletonWorkspaceList skeletonNum={8} />}> | ||
<WorkspaceContainer /> | ||
</Suspense> | ||
</section> | ||
); | ||
}; |
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
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
Oops, something went wrong.
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.
컴포넌트 의미가 좀 더 명확해져서 좋네요!