-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from hufs-sports-live/feat/admin-league
[FEAT]: `/admin/league` 라우트 구현
- Loading branch information
Showing
33 changed files
with
1,202 additions
and
179 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 |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"style", | ||
"chore" | ||
] | ||
] | ||
], | ||
"subject-case": [0] | ||
} | ||
} |
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,48 @@ | ||
import { adminInstance } from '@/api'; | ||
import { | ||
DeleteLeaguePayload, | ||
LeagueIdType, | ||
LeagueType, | ||
NewLeaguePayload, | ||
PutLeaguePayload, | ||
SportsCategoriesType, | ||
SportsQuarterType, | ||
} from '@/types/admin/league'; | ||
|
||
export const getAllLeaguesWithAuth = async () => { | ||
const { data } = await adminInstance.get<LeagueType[]>('/league/all/'); | ||
|
||
return data; | ||
}; | ||
|
||
export const postNewLeagueWithAuth = async (body: NewLeaguePayload) => { | ||
const { data } = await adminInstance.post<LeagueIdType>('/league/', body); | ||
|
||
return data; | ||
}; | ||
|
||
export const deleteLeagueByIdWithAuth = async (body: DeleteLeaguePayload) => { | ||
const { status } = await adminInstance.delete('/league/', { data: body }); | ||
|
||
return status; | ||
}; | ||
|
||
export const putLeagueWithAuth = async (data: PutLeaguePayload) => { | ||
await adminInstance.put('/league/', data); | ||
|
||
return data.leagueId; | ||
}; | ||
|
||
export const getSportsCategoriesWithAuth = async () => { | ||
const { data } = await adminInstance.get<SportsCategoriesType[]>('/sport/'); | ||
|
||
return data; | ||
}; | ||
|
||
export const getSportsQuarterByIdWithAuth = async (sportId: string) => { | ||
const { data } = await adminInstance.get<SportsQuarterType[]>( | ||
`/sport/${sportId}/quarter/`, | ||
); | ||
|
||
return data; | ||
}; |
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,46 @@ | ||
import { isAxiosError } from 'axios'; | ||
|
||
import { adminInstance } from '@/api'; | ||
import { TeamErrorType, TeamType } from '@/types/admin/team'; | ||
|
||
/* 리그 내 팀 관리 API */ | ||
|
||
export const getTeamListByLeagueIdWithAuth = async (leagueId: string) => { | ||
try { | ||
const { data } = await adminInstance.get<TeamType[]>(`/team/${leagueId}/`); | ||
|
||
return data; | ||
} catch (error) { | ||
if (isAxiosError<TeamErrorType>(error)) { | ||
return error.response?.data.detail; | ||
} else { | ||
throw new Error('리그 내 팀을 조회하는데 실패했습니다.'); | ||
} | ||
} | ||
}; | ||
|
||
export const postTeamByLeagueIdWithAuth = async (payload: { | ||
leagueId: string; | ||
body: FormData; | ||
}) => { | ||
await adminInstance.post( | ||
`/team/register/${payload.leagueId}/`, | ||
payload.body, | ||
{ | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}, | ||
); | ||
}; | ||
|
||
export const putTeamByIdWithAuth = async (payload: { | ||
teamId: string; | ||
body: FormData; | ||
}) => { | ||
await adminInstance.put(`/team/${payload.teamId}/change/`, payload.body, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', | ||
}, | ||
}); | ||
}; |
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,26 @@ | ||
'use client'; | ||
|
||
import Link from 'next/link'; | ||
import { Suspense } from 'react'; | ||
|
||
import LeagueList from '@/components/admin/league/LeagueList'; | ||
import Button from '@/components/common/Button'; | ||
import LeagueListFetcher from '@/queries/admin/useLeagueList/Fetcher'; | ||
|
||
export default function LeaguePage() { | ||
return ( | ||
<div className="space-y-8 py-8"> | ||
<div className="text-2xl font-medium">전체 리그</div> | ||
<Suspense fallback={<div>리그 로딩중...</div>}> | ||
<LeagueListFetcher> | ||
{data => <LeagueList data={data} />} | ||
</LeagueListFetcher> | ||
</Suspense> | ||
<Button className="w-full rounded-lg bg-primary p-3 text-white hover:bg-[#303ECE]"> | ||
<Link href="/admin/register" className="w-full"> | ||
새 리그 등록 | ||
</Link> | ||
</Button> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
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,30 @@ | ||
'use client'; | ||
|
||
import { Suspense } from 'react'; | ||
|
||
import RegisterLeague from '@/components/admin/register/League'; | ||
import LeagueRegisterFetcher from '@/queries/admin/useLeagueRegister/Fetcher'; | ||
import useSportsListByLeagueId from '@/queries/useSportsListByLeagueId/query'; | ||
|
||
export default function EditLeague({ | ||
params, | ||
}: { | ||
params: { leagueId: string }; | ||
}) { | ||
const { leagueId } = params; | ||
const { sportsList: leagueSportsData } = useSportsListByLeagueId(leagueId); | ||
return ( | ||
<div className="space-y-8 py-8"> | ||
<Suspense fallback={<div>리그 정보 로딩중...</div>}> | ||
<LeagueRegisterFetcher> | ||
{data => ( | ||
<RegisterLeague | ||
data={{ ...data, leagueSportsData }} | ||
leagueId={Number(leagueId)} | ||
/> | ||
)} | ||
</LeagueRegisterFetcher> | ||
</Suspense> | ||
</div> | ||
); | ||
} |
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,44 @@ | ||
'use client'; | ||
|
||
import { Suspense } from 'react'; | ||
|
||
import RegisterWrapper from '@/components/admin/register/context/RegisterWrapper'; | ||
import RegisterLeague from '@/components/admin/register/League'; | ||
import RegisterTeam from '@/components/admin/register/Team'; | ||
import { useFunnel } from '@/hooks/useFunnel'; | ||
import LeagueRegisterFetcher from '@/queries/admin/useLeagueRegister/Fetcher'; | ||
import TeamRegisterFetcher from '@/queries/admin/useTeamRegister/Fetcher'; | ||
|
||
export default function Register() { | ||
const [Funnel, setStep] = useFunnel(['league', 'team', 'player'], 'league'); | ||
|
||
return ( | ||
<RegisterWrapper className="space-y-8 py-8"> | ||
<Funnel> | ||
<Funnel.Step name="league"> | ||
<Suspense fallback={<div>리그 정보 로딩중...</div>}> | ||
<LeagueRegisterFetcher> | ||
{data => ( | ||
<RegisterLeague data={data} onNext={() => setStep('team')} /> | ||
)} | ||
</LeagueRegisterFetcher> | ||
</Suspense> | ||
</Funnel.Step> | ||
<Funnel.Step name="team"> | ||
<Suspense fallback={<div>팀 정보 로딩중...</div>}> | ||
<TeamRegisterFetcher> | ||
{data => <RegisterTeam data={data} />} | ||
</TeamRegisterFetcher> | ||
</Suspense> | ||
</Funnel.Step> | ||
<Funnel.Step name="player"> | ||
<Suspense fallback={<div>선수 정보 로딩중...</div>}> | ||
{/* <LeagueRegisterFetcher leagueId={leagueId}> | ||
{data => <RegisterLeague data={data} leagueId={leagueId} />} | ||
</LeagueRegisterFetcher> */} | ||
</Suspense> | ||
</Funnel.Step> | ||
</Funnel> | ||
</RegisterWrapper> | ||
); | ||
} |
Oops, something went wrong.