-
Notifications
You must be signed in to change notification settings - Fork 2
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
[FEAT]: 관리자 매치 정보 수정 구현 #126
Changes from all commits
9569636
5a52ffb
19f894c
9426c9f
5923be8
f967eff
09d027c
5621ea0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
MatchInfoType, | ||
PutMatchInfoPayload, | ||
SportsQuarterType, | ||
} from '@/types/admin/match'; | ||
|
||
import { adminInstance } from '..'; | ||
|
||
export const getMatchInfoByIdWithAuth = async (matchId: string) => { | ||
const { data } = await adminInstance.get<MatchInfoType>( | ||
`/game/info/${matchId}/`, | ||
); | ||
|
||
return data; | ||
}; | ||
|
||
export const putMatchInfoWithAuth = async (payload: { | ||
matchId: string; | ||
data: PutMatchInfoPayload; | ||
}) => { | ||
await adminInstance.put(`/game/change/${payload.matchId}/`, payload.data); | ||
|
||
return payload.matchId; | ||
}; | ||
|
||
export const getSportsQuarterByIdWithAuth = async (sportId: number) => { | ||
const { data } = await adminInstance.get<SportsQuarterType[]>( | ||
`/sport/${sportId}/quarter/`, | ||
); | ||
|
||
return data; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use client'; | ||
|
||
import LeagueIdWrapper from '@/components/admin/context/LeagueIdWrapper'; | ||
|
||
export default function AdminLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode; | ||
}) { | ||
return ( | ||
<LeagueIdWrapper> | ||
<section className="space-y-8">{children}</section> | ||
</LeagueIdWrapper> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use client'; | ||
|
||
import MatchInfoDetail from '@/components/admin/match/detail/Info'; | ||
import AsyncBoundary from '@/components/common/AsyncBoundary'; | ||
import AuthMatchInfoFetcher from '@/queries/admin/match/useMatchInfoByIdWithAuth/Fetcher'; | ||
|
||
export default function Page({ | ||
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. 컴포넌트명을 단순히 Page로 작성한 이유가 있을까요? 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. 이것또한 레포가 분리돼있지 않아서 페이지 컴포넌트명을 작명하는데 좀 어려움이 많아 그냥 Page로 통일시켜버렸습니다. 저희 프로젝트 구조상 페이지 컴포넌트 자체에 기능들이 곧바로 작성돼있는게 아니라 기능별 서브 컴포넌트로 분리되어 호출하고 있는 방식이기 때문에 페이지 컴포넌트 자체에 이름을 붙이는게 큰 의미가 없다고 판단했습니다. 추후 레포를 분리하게 되면 이 부분에 있어 제약이 줄어듦에 따라 다른 컨벤션을 적용할 수도 있을 것 같습니다. |
||
params, | ||
}: { | ||
params: { matchId: string; leagueId: string }; | ||
}) { | ||
const { matchId } = params; | ||
|
||
return ( | ||
<section> | ||
<AsyncBoundary | ||
errorFallback={props => <MatchInfoDetail.ErrorFallback {...props} />} | ||
loadingFallback={<div>로딩 중입니다...</div>} | ||
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. 나중에 loading fallback도 추가해주시면 좋을 것 같아요! 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. 넵 확인했습니다. 에러/로딩 fallback도 레포 분리 이후에 제대로 작성하는 시간을 가져야할 것 같습니다. |
||
> | ||
<AuthMatchInfoFetcher matchId={matchId}> | ||
{data => { | ||
return <MatchInfoDetail {...{ ...data, params }} />; | ||
}} | ||
</AuthMatchInfoFetcher> | ||
</AsyncBoundary> | ||
</section> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use client'; | ||
|
||
import { useEffect } from 'react'; | ||
|
||
import { checkPermission } from '@/api/auth'; | ||
import Home from '@/app/page'; | ||
import { QUERY_PARAMS } from '@/constants/queryParams'; | ||
import useQueryParams from '@/hooks/useQueryParams'; | ||
|
||
export default function Page({ params }: { params: { leagueId: string } }) { | ||
const { leagueId } = params; | ||
const { setInParams } = useQueryParams(); | ||
|
||
useEffect(() => { | ||
setInParams(QUERY_PARAMS.league, leagueId); | ||
checkPermission(); | ||
}); | ||
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. 의존성 배열을 잘 작성해주는 것이 좋을 것 같아요! 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. 해당 useEffect는 컴포넌트 최초 마운트시에만 작동하도록 의도해서 의존성 배열을 추가한다하더라도 빈 배열을 추가하기 때문에 딱히 의미가 없긴 한데 그래도 추가하는게 좋을까요? 왜냐하면 빈 배열을 추가하는게 에러는 아니지만 lint에도 |
||
|
||
return ( | ||
<> | ||
<div className="text-2xl font-medium">리그 내 매치 </div> | ||
<Home /> | ||
</> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
'use client'; | ||
|
||
import { Suspense, useEffect } from 'react'; | ||
|
||
import LeagueDetail from '@/components/admin/league/detail'; | ||
import { useLeagueIdContext } from '@/hooks/useLeagueIdContext'; | ||
import LeagueRegisterFetcher from '@/queries/admin/league/useLeagueRegister/Fetcher'; | ||
import useSportsListByLeagueId from '@/queries/useSportsListByLeagueId/query'; | ||
|
||
export default function Page({ params }: { params: { leagueId: string } }) { | ||
const { leagueId } = params; | ||
const { setLeagueId } = useLeagueIdContext(); | ||
const { sportsList: leagueSportsData } = useSportsListByLeagueId(leagueId); | ||
|
||
useEffect(() => { | ||
setLeagueId(leagueId); | ||
}, []); | ||
|
||
return ( | ||
<Suspense fallback={<div>리그 정보 로딩중...</div>}> | ||
<LeagueRegisterFetcher> | ||
{data => ( | ||
<LeagueDetail | ||
data={{ ...data, leagueSportsData }} | ||
leagueId={leagueId} | ||
/> | ||
)} | ||
</LeagueRegisterFetcher> | ||
</Suspense> | ||
); | ||
} |
This file was deleted.
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.
궁금한 게 있는데, tanstack query의 retry 옵션으로 재요청을 보내는 것과 어떤 차이가 있을까요?
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.
아 tanstack query는 그 성격이 react hook이다보니까 jsx(tsx)내부에서밖에 사용하지 못합니다. 그래서 해당 파일은 일반 타입스크립트 파일이기 때문에 해당 기능을 사용하지 못했습니다!