-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: event loader를 이용해서 이벤트에 필요한 정보 병렬적으로 데이터 불러옴 * refactor: 총 금액 업데이트 계산을 로더에서 제거
- Loading branch information
1 parent
986bcf1
commit 5d5d9f1
Showing
2 changed files
with
44 additions
and
2 deletions.
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import {useQueries} from '@tanstack/react-query'; | ||
|
||
import {requestGetEvent} from '@apis/request/event'; | ||
import {requestGetReports} from '@apis/request/report'; | ||
import {requestGetSteps} from '@apis/request/step'; | ||
import {WithErrorHandlingStrategy} from '@errors/RequestGetError'; | ||
|
||
import getEventIdByUrl from '@utils/getEventIdByUrl'; | ||
|
||
import QUERY_KEYS from '@constants/queryKeys'; | ||
|
||
const EventLoader = ({children, ...props}: React.PropsWithChildren<WithErrorHandlingStrategy | null> = {}) => { | ||
const eventId = getEventIdByUrl(); | ||
|
||
const queries = useQueries({ | ||
queries: [ | ||
{queryKey: [QUERY_KEYS.event], queryFn: () => requestGetEvent({eventId, ...props})}, | ||
{ | ||
queryKey: [QUERY_KEYS.reports], | ||
queryFn: () => requestGetReports({eventId, ...props}), | ||
}, | ||
{ | ||
queryKey: [QUERY_KEYS.steps], | ||
queryFn: () => requestGetSteps({eventId, ...props}), | ||
}, | ||
], | ||
}); | ||
|
||
const isLoading = queries.some(query => query.isLoading === true); | ||
|
||
return !isLoading && children; | ||
}; | ||
|
||
export default EventLoader; |
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