-
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.
feat(my-recruit): 내 공고 뽀각 페이지 api 연결 (#28)
* feat(my-recruit): 내정보뽀각 페이지 api 연결 * update * save * save
- Loading branch information
1 parent
c4ac4f4
commit 9ed1ee0
Showing
48 changed files
with
1,027 additions
and
448 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,25 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { GET_PROGRESSING_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetProgressingRecruits'; | ||
import { GET_ALL_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetAllRecruits'; | ||
|
||
export const DELETE_RECRUIT_KEY = 'delete-recruit'; | ||
|
||
export const deleteRecruit = (recruitId: number) => | ||
http.delete({ | ||
url: `/recruits/${recruitId}`, | ||
}); | ||
|
||
export const useDeleteRecruit = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
const mutate = useMutation({ | ||
mutationFn: (recruitId: number) => deleteRecruit(recruitId), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: [GET_PROGRESSING_RECRUITS_KEY] }); | ||
queryClient.invalidateQueries({ queryKey: [GET_ALL_RECRUITS_KEY] }); | ||
}, | ||
}); | ||
|
||
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 { 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_ALL_RECRUITS_KEY = 'recruits-all'; | ||
|
||
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_ALL_RECRUITS_KEY, 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; | ||
} |
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,29 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { GET_PROGRESSING_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetProgressingRecruits'; | ||
import { GET_ALL_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetAllRecruits'; | ||
|
||
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 queryClient = useQueryClient(); | ||
|
||
const mutate = useMutation({ | ||
mutationFn: (data: Request) => patchRecruitStatus(data), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: [GET_PROGRESSING_RECRUITS_KEY] }); | ||
queryClient.invalidateQueries({ queryKey: [GET_ALL_RECRUITS_KEY] }); | ||
}, | ||
}); | ||
|
||
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: `/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,32 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
import { GET_PROGRESSING_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetProgressingRecruits'; | ||
import { GET_ALL_RECRUITS_KEY } from '@/app/(sidebar)/my-recruit/api/useGetAllRecruits'; | ||
|
||
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 queryClient = useQueryClient(); | ||
|
||
const mutate = useMutation({ | ||
mutationFn: (data: Request) => postRecruit(data), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: [GET_PROGRESSING_RECRUITS_KEY] }); | ||
queryClient.invalidateQueries({ queryKey: [GET_ALL_RECRUITS_KEY] }); | ||
}, | ||
}); | ||
|
||
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.