-
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.
- Loading branch information
1 parent
79e6cd2
commit 22d1daf
Showing
40 changed files
with
870 additions
and
409 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file not shown.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
export const DELETE_RECRUIT_KEY = 'delete-recruit'; | ||
|
||
export const deleteRecruit = (recruitId: number) => | ||
http.delete({ | ||
url: `/recruits/${recruitId}`, | ||
}); | ||
|
||
export const useDeleteRecruit = () => | ||
useMutation({ | ||
mutationKey: [DELETE_RECRUIT_KEY], | ||
mutationFn: (recruitId: number) => deleteRecruit(recruitId), | ||
}); |
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,27 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { RecruitCard } from '@/app/(sidebar)/my-recruit/type'; | ||
import { ALL_RECRUITMENT } from '@/app/(sidebar)/my-recruit/containers/components/SeasonDropdownContent'; | ||
|
||
type Request = { season: string }; | ||
|
||
type Response = { data: RecruitCard[] }; | ||
|
||
export const GET_RECRUITS = 'recruits'; | ||
|
||
function getAllRecruits() { | ||
return http.get({ url: '/recruits' }); | ||
} | ||
|
||
function getRecruitsBySeason({ season }: Request) { | ||
return http.get({ url: '/recruits/bySeason', params: { season } }); | ||
} | ||
|
||
export function useGetAllRecruits({ season }: Request) { | ||
const result = useSuspenseQuery({ | ||
queryKey: [GET_RECRUITS, season], | ||
queryFn: season === ALL_RECRUITMENT ? getAllRecruits : () => getRecruitsBySeason({ season }), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
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,28 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { TagType } from '@/types/info'; | ||
|
||
interface Props { | ||
type: string; | ||
} | ||
|
||
interface Response { | ||
data: Array<{ | ||
id: number; | ||
title: string; | ||
updatedDate: string; | ||
tagList: Array<TagType>; | ||
}>; | ||
} | ||
|
||
export const GET_CARDS = 'cards'; | ||
|
||
function getCards({ type }: Props) { | ||
return http.get({ url: '/cards', params: { type } }); | ||
} | ||
|
||
export function useGetCards({ type }: Props) { | ||
const result = useSuspenseQuery({ queryKey: [GET_CARDS, type], queryFn: () => getCards({ type }) }); | ||
|
||
return result.data as unknown as Response; | ||
} |
20 changes: 20 additions & 0 deletions
20
src/app/(sidebar)/my-recruit/api/useGetProgressingRecruits.ts
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 { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { RecruitCard } from '@/app/(sidebar)/my-recruit/type'; | ||
|
||
type Response = { data: RecruitCard[] }; | ||
|
||
export const GET_PROGRESSING_RECRUITS_KEY = 'recruits-progressing'; | ||
|
||
function getProgressingRecruits() { | ||
return http.get({ url: '/recruits/progressing' }); | ||
} | ||
|
||
export function useGetProgressingRecruits() { | ||
const result = useSuspenseQuery({ | ||
queryKey: [GET_PROGRESSING_RECRUITS_KEY], | ||
queryFn: getProgressingRecruits, | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/app/(sidebar)/my-recruit/api/useGetRecruitsBySeason.ts
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 { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { RecruitCard } from '@/app/(sidebar)/my-recruit/type'; | ||
|
||
type Request = { season: string }; | ||
|
||
type Response = { data: RecruitCard[] }; | ||
|
||
export const GET_RECRUIT_BY_SEASON_KEY = 'recruits-by-season'; | ||
|
||
function getRecruitsBySeason({ season }: Request) { | ||
return http.get({ url: '/recruits/bySeason', params: { season } }); | ||
} | ||
|
||
export function useGetRecruitsBySeason({ season }: Request) { | ||
const result = useSuspenseQuery({ | ||
queryKey: [GET_RECRUIT_BY_SEASON_KEY, season], | ||
queryFn: () => getRecruitsBySeason({ season }), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
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 { useSuspenseQuery } from '@tanstack/react-query'; | ||
import { http } from '@/apis/http'; | ||
|
||
type Response = { | ||
data: Array<{ | ||
name: string; | ||
}>; | ||
}; | ||
|
||
export const GET_SEASONS_KEY = 'seasons'; | ||
|
||
function getSeasons() { | ||
return http.get({ url: '/seasons' }); | ||
} | ||
|
||
export function useGetSeasons() { | ||
const result = useSuspenseQuery({ queryKey: [GET_SEASONS_KEY], queryFn: getSeasons }); | ||
|
||
return result.data as unknown as Response; | ||
} |
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 { http } from '@/apis/http'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
interface Request { | ||
id: number; | ||
recruitStatus: string; | ||
} | ||
|
||
export const PATCH_RECRUIT_STATUS_KEY = 'put-recruit-status'; | ||
|
||
function patchRecruitStatus({ id, recruitStatus }: Request) { | ||
return http.patch({ url: `/recruits/${id}/status`, data: { recruitStatus } }); | ||
} | ||
|
||
export function usePatchRecruitStatus() { | ||
const mutate = useMutation({ | ||
mutationKey: [PATCH_RECRUIT_STATUS_KEY], | ||
mutationFn: (data: Request) => patchRecruitStatus(data), | ||
}); | ||
|
||
return mutate; | ||
} |
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 { http } from '@/apis/http'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
interface Request { | ||
recruitId: number; | ||
cardId: number; | ||
} | ||
|
||
export const POST_CARD_TO_RECRUIT_KEY = 'post-card-to-recruit'; | ||
|
||
function postCardToRecruit({ recruitId, cardId }: Request) { | ||
return http.post({ url: `/api/v1/recruits/${recruitId}/cards/${cardId}` }); | ||
} | ||
|
||
export function usePostCardToRecruit() { | ||
const mutate = useMutation({ | ||
mutationKey: [POST_CARD_TO_RECRUIT_KEY], | ||
mutationFn: (data: Request) => postCardToRecruit(data), | ||
}); | ||
|
||
return mutate; | ||
} |
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,27 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
export interface Request { | ||
title: string; | ||
season: string; | ||
siteUrl: string; | ||
recruitScheduleStage: string; | ||
deadline: string | null; | ||
} | ||
|
||
export const POST_RECRUIT_KEY = 'post-recruit'; | ||
|
||
function postRecruit(data: Request) { | ||
return http.post({ url: '/recruits', data }); | ||
} | ||
|
||
export function usePostRecruit() { | ||
const { invalidateQueries } = useQueryClient(); | ||
|
||
const mutate = useMutation({ | ||
mutationKey: [POST_RECRUIT_KEY], | ||
mutationFn: (data: Request) => postRecruit(data), | ||
}); | ||
|
||
return mutate; | ||
} |
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.