-
Notifications
You must be signed in to change notification settings - Fork 2
feat(web): 선수 관리 페이지 추가 #410
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
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
139b0e9
feat: exclude test files from biome scanner includes
ohprettyhak ad786f9
feat: add player management page with edit functionality
ohprettyhak 031258e
feat: implement player management functionality with player list and …
ohprettyhak 0f566e9
feat: enhance player management page with search functionality and im…
ohprettyhak a5a60b1
feat: add Modal component and integrate with player management page
ohprettyhak d02f42f
feat: add AlertDialog component for player deletion confirmation
ohprettyhak dea7c99
feat: enhance player list display with student number and adjust typo…
ohprettyhak ae69278
feat: add spinner component with customizable size and color, and enh…
ohprettyhak 6d42bd6
feat: add loading state to Button component and integrate Spinner for…
ohprettyhak 68eeb32
feat: add search functionality to player list with input field for fi…
ohprettyhak b28eb8f
feat: add player management page with add player button and update pl…
ohprettyhak 113270c
feat: add player creation and update functionality with form handling…
ohprettyhak d3b612e
feat: refactor player delete menu import path for better module organ…
ohprettyhak 315b916
feat: update player form to display message when no teams are available
ohprettyhak d4c5916
feat: improve loading state handling in alert dialog and refactor pla…
ohprettyhak 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 hidden or 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 hidden or 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 +1,4 @@ | ||
| export * from './useCreatePlayers'; | ||
| export * from './useDeletePlayers'; | ||
| export * from './useLogin'; | ||
| export * from './useUpdatePlayers'; |
This file contains hidden or 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 { fetcher, useMutation, useQueryClient } from '@hcc/api-base'; | ||
| import type { PlayerType } from '~/api'; | ||
| import { queryKeys } from '~/api/queryKey'; | ||
|
|
||
| export type PlayerFormType = Pick<PlayerType, 'name' | 'studentNumber'>; | ||
|
|
||
| export const postPlayers = (request: PlayerFormType) => { | ||
| return fetcher.post<void>('players', { json: request }); | ||
| }; | ||
|
|
||
| export const useCreatePlayers = () => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| return useMutation({ | ||
| mutationFn: postPlayers, | ||
| onSuccess: async () => { | ||
| await queryClient.invalidateQueries({ queryKey: queryKeys.players._def }); | ||
| }, | ||
| }); | ||
| }; |
This file contains hidden or 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,21 @@ | ||
| import { fetcher, useMutation, useQueryClient } from '@hcc/api-base'; | ||
| import { queryKeys } from '~/api/queryKey'; | ||
|
|
||
| type Request = { | ||
| id: number; | ||
| }; | ||
|
|
||
| export const deletePlayers = ({ id }: Request) => { | ||
| return fetcher.delete<void>(`players/${id}`, { json: null }); | ||
| }; | ||
|
|
||
| export const useDeletePlayers = () => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| return useMutation({ | ||
| mutationFn: deletePlayers, | ||
| onSuccess: async () => { | ||
| await queryClient.invalidateQueries({ queryKey: queryKeys.players._def }); | ||
| }, | ||
| }); | ||
| }; |
This file contains hidden or 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 { fetcher, useMutation, useQueryClient } from '@hcc/api-base'; | ||
| import type { PlayerFormType } from '~/api'; | ||
| import { queryKeys } from '~/api/queryKey'; | ||
|
|
||
| type Request = { | ||
| id: number; | ||
| } & PlayerFormType; | ||
|
|
||
| export const patchPlayers = ({ id, ...request }: Request) => { | ||
| return fetcher.patch<void>(`players/${id}`, { json: request }); | ||
| }; | ||
|
|
||
| export const useUpdatePlayers = () => { | ||
| const queryClient = useQueryClient(); | ||
|
|
||
| return useMutation({ | ||
| mutationFn: patchPlayers, | ||
| onSuccess: async () => { | ||
| await queryClient.invalidateQueries({ queryKey: queryKeys.players._def }); | ||
| }, | ||
| }); | ||
| }; |
This file contains hidden or 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,2 +1,4 @@ | ||
| export * from './useLeaguesHome'; | ||
| export * from './useLeaguesLeague'; | ||
| export * from './usePlayer'; | ||
| export * from './usePlayers'; |
This file contains hidden or 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,9 @@ | ||
| import { useQuery, useSuspenseQuery } from '@hcc/api-base'; | ||
| import type { PlayerDetailPayload } from '~/api'; | ||
| import { queryKeys } from '../queryKey'; | ||
|
|
||
| export const usePlayer = (payload: PlayerDetailPayload) => | ||
| useQuery(queryKeys.players.detail(payload)); | ||
|
|
||
| export const useSuspensePlayer = (payload: PlayerDetailPayload) => | ||
| useSuspenseQuery(queryKeys.players.detail(payload)); |
This file contains hidden or 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,6 @@ | ||
| import { useQuery, useSuspenseQuery } from '@hcc/api-base'; | ||
| import { queryKeys } from '../queryKey'; | ||
|
|
||
| export const usePlayers = () => useQuery(queryKeys.players.list); | ||
|
|
||
| export const useSuspensePlayers = () => useSuspenseQuery(queryKeys.players.list); |
This file contains hidden or 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 hidden or 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 type { TeamType } from '~/api/types/teams'; | ||
| import type { GameTeamType } from '~/api/types/teams'; | ||
|
|
||
| export type GameType = { | ||
| id: number; | ||
| isPkTaken: boolean; | ||
| startTime: string; | ||
| gameQuarter: string; | ||
| gameName: string; | ||
| round: number; | ||
| videoId: string; | ||
| gameTeams: TeamType[]; | ||
| isPkTaken: boolean; | ||
| gameTeams: GameTeamType[]; | ||
| }; |
This file contains hidden or 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,4 @@ | ||
| export * from './games'; | ||
| export * from './leagues'; | ||
| export * from './players'; | ||
| export * from './teams'; |
This file contains hidden or 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,13 @@ | ||
| import type { TeamType } from '~/api'; | ||
|
|
||
| export type PlayerType = { | ||
| playerId: number; | ||
ohprettyhak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| name: string; | ||
| studentNumber: string; | ||
| totalGoalCount: number; | ||
| teams: TeamType[]; | ||
| }; | ||
|
|
||
| export type PlayerDetailPayload = { | ||
| id: number; | ||
| }; | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 { toast } from '@hcc/ui'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import { type PlayerFormType, useSuspensePlayer, useUpdatePlayers } from '~/api'; | ||
| import { PlayerForm } from '../_components/player-form'; | ||
|
|
||
| type Props = { | ||
| id: number; | ||
| }; | ||
|
|
||
| export const FormSection = ({ id }: Props) => { | ||
| const router = useRouter(); | ||
|
|
||
| const { mutateAsync } = useUpdatePlayers(); | ||
| const handleSubmit = async (data: PlayerFormType) => { | ||
| try { | ||
| await mutateAsync({ id, ...data }); | ||
| toast.success('선수가 수정되었어요.'); | ||
| router.back(); | ||
| } catch (error) { | ||
| console.error(error); | ||
| toast.error('선수 수정에 실패했어요.'); | ||
| } | ||
| }; | ||
|
|
||
| const { data } = useSuspensePlayer({ id }); | ||
|
|
||
| return <PlayerForm className="p-5" onSubmit={handleSubmit} initialData={data} />; | ||
| }; |
This file contains hidden or 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,43 @@ | ||
| import { Spinner } from '@hcc/ui'; | ||
| import { Suspense } from '@suspensive/react'; | ||
| import { notFound } from 'next/navigation'; | ||
| import { Header } from '~/components/layout'; | ||
| import { TipBanner } from '../_components/tip-banner'; | ||
| import { FormSection } from './form-section'; | ||
| import { PlayerDeleteMenu } from './player-delete-menu'; | ||
|
|
||
| type Props = { | ||
| params: Promise<{ id: number }>; | ||
| }; | ||
|
|
||
| const Page = async ({ params }: Props) => { | ||
| const { id: _id } = await params; | ||
ohprettyhak marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (!_id || Number.isNaN(_id)) { | ||
| notFound(); | ||
| } | ||
|
|
||
| const id: number = Number(_id); | ||
|
|
||
| return ( | ||
| <> | ||
| <Header title="선수 수정" menu={<PlayerDeleteMenu id={id} />} arrow /> | ||
|
|
||
| <div className="column-between h-full overflow-hidden"> | ||
| <Suspense | ||
| fallback={ | ||
| <div className="center p-5"> | ||
| <Spinner size="lg" color="neutral" /> | ||
| </div> | ||
| } | ||
| clientOnly | ||
| > | ||
| <FormSection id={id} /> | ||
| </Suspense> | ||
| <TipBanner /> | ||
| </div> | ||
| </> | ||
| ); | ||
| }; | ||
|
|
||
| export default Page; | ||
This file contains hidden or 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,35 @@ | ||
| 'use client'; | ||
|
|
||
| import { Typography, toast } from '@hcc/ui'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import { useDeletePlayers } from '~/api'; | ||
| import { AlertDialog } from '~/components/ui'; | ||
|
|
||
| export const PlayerDeleteMenu = ({ id }: { id: number }) => { | ||
| const router = useRouter(); | ||
| const { mutateAsync } = useDeletePlayers(); | ||
|
|
||
| const handlePlayerDelete = async (playerId: number): Promise<void> => { | ||
| try { | ||
| await mutateAsync({ id: playerId }); | ||
| toast.success('선수가 삭제되었어요.'); | ||
| router.back(); | ||
| } catch (error) { | ||
| console.error(error); | ||
| toast.error('선수 삭제에 실패했어요.'); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <AlertDialog | ||
| title="삭제한 선수는 다시 복구할 수 없어요" | ||
| description="정말 삭제할까요?" | ||
| primaryTitle="삭제" | ||
| onPrimaryClick={() => handlePlayerDelete(id)} | ||
| > | ||
| <Typography className="cursor-pointer" color="var(--color-danger-600)" weight="semibold"> | ||
| 삭제 | ||
| </Typography> | ||
| </AlertDialog> | ||
| ); | ||
| }; |
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.
Uh oh!
There was an error while loading. Please reload this page.