-
Notifications
You must be signed in to change notification settings - Fork 0
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
내 공고 폴더 내부 구현 #40
내 공고 폴더 내부 구현 #40
Changes from 65 commits
c08df09
55cb010
47b86bf
17edfd6
7755182
5fca049
a22b2bd
cb42bed
65aea6c
dc38bf3
be3bb3c
f0aeac0
3111777
1da0d27
c6a9d49
0b9a0ad
1f4c84c
7058bc2
5234fb5
848dc60
e6f6993
8046e24
4f1fc9b
5d9e0eb
300107c
c4ac4f4
9ed1ee0
732fe28
188b4cc
18a429d
52fe24b
07dc1df
2df3079
02bcbb5
5acc554
71e375e
4b0ccd7
8def9d9
1d3b92a
e176335
11ddcdd
bb2847c
dff129e
5048afd
b80db9e
3487aaa
1cd7efa
8f3c799
6d3cf85
8bd9f19
a2d33e5
e77101f
7745f42
cb2505f
e55bb85
4de3786
847af0b
f367bd5
29aacd9
821663d
7b604e9
837500d
84aa0f7
587a56d
4ae2e4a
e726b2b
86fb9be
5ff8afc
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 |
---|---|---|
|
@@ -31,6 +31,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
const deleteRecruit = (id: string) => { | ||
return http.delete({ | ||
url: `/recruits/${id}`, | ||
}); | ||
}; | ||
|
||
export const useDeleteRecruit = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: deleteRecruit, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['info-card-list'] }); | ||
queryClient.invalidateQueries({ queryKey: ['card-type-count'] }); | ||
}, | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { http } from '@/apis/http'; | ||
import { TagType } from '@/types'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
type Response = { data: TagType[] }; | ||
|
||
const getAllTags = () => { | ||
return http.get<TagType[]>({ | ||
url: `/tags`, | ||
}); | ||
}; | ||
|
||
export function useGetAllTags() { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-all-tags'], | ||
queryFn: () => getAllTags(), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
type getCardCountType = Record<'서류_준비' | '과제_준비' | '인터뷰_준비', number>; | ||
|
||
type Response = { data: getCardCountType }; | ||
|
||
const getCardCount = (id: string) => { | ||
return http.get<getCardCountType>({ | ||
url: `/recruits/${id}/cards/type-count`, | ||
}); | ||
}; | ||
|
||
export function useGetCardCount(id: string) { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-progress-recruit'], | ||
queryFn: () => getCardCount(id), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
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. 타입 단언이 없어도 될 것 같고, useSuspenseQuery에서 반환하는 result를 그대로 반환하는건 어떨까요? 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. 아 이거 자세히 보니 그러면 queryFn에서 data를 한 번 걸러서 반환해주는건 어떤가요?? queryFn: async () => {
const res = await getCardCount(id);
return res.data;
} |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
export interface NearestScheduleType { | ||
id: number; | ||
recruitScheduleStage: string; | ||
deadLine: string; | ||
} | ||
|
||
export interface ProgressRecruitType { | ||
id: number; | ||
title: string; | ||
season: string; | ||
siteUrl: string; | ||
recruitStatus: string; | ||
createdDate: string; | ||
nearestSchedule: NearestScheduleType | null; | ||
} | ||
|
||
const getProgressRecruit = () => { | ||
return http.get<ProgressRecruitType[]>({ | ||
url: `/recruits/progressing`, | ||
}); | ||
}; | ||
|
||
export function useGetProgressRecruit() { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-progress-recruit'], | ||
queryFn: () => getProgressRecruit(), | ||
}); | ||
|
||
return result.data as unknown as ProgressRecruitType[]; | ||
} |
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'; | ||
|
||
interface recruitByIdType { | ||
id: number; | ||
title: string; | ||
season: string; | ||
siteUrl: string; | ||
recruitStatus: string; | ||
} | ||
|
||
type Response = { data: recruitByIdType }; | ||
|
||
const getRecruitById = (id: string) => { | ||
return http.get<recruitByIdType>({ | ||
url: `/recruits/${id}`, | ||
}); | ||
}; | ||
|
||
export function useGetRecruitById(id: string) { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-recruit-by-id', id], | ||
queryFn: () => getRecruitById(id), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
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. 다른 query 훅에서도 위 코멘트와 동일합니다! |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { http } from '@/apis/http'; | ||
import { TagType } from '@/types'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
export type GetRecruitCardsType = { | ||
id: number; | ||
title: string; | ||
updatedDate: string; | ||
tagList: TagType[]; | ||
}; | ||
|
||
type Response = { data: GetRecruitCardsType[] }; | ||
|
||
const getRecruitCards = ({ id, progress }: { id: string; progress: string }) => { | ||
return http.get<GetRecruitCardsType[]>({ | ||
url: `recruits/${id}/cards?type=${progress}`, | ||
}); | ||
}; | ||
|
||
export function useGetRecruitCards({ id, progress }: { id: string; progress: string }) { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-recruit-card-id', id, progress], | ||
queryFn: () => getRecruitCards({ id, progress }), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
export interface SeasonType { | ||
name: string; | ||
} | ||
|
||
type Response = { data: SeasonType[] }; | ||
|
||
const getSeasons = () => { | ||
return http.get<SeasonType[]>({ | ||
url: `/seasons`, | ||
}); | ||
}; | ||
|
||
export function useGetSeasons() { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-seasons'], | ||
queryFn: () => getSeasons(), | ||
}); | ||
|
||
return result.data as unknown as Response; | ||
} |
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 { ProgressRecruitType } from './useGetProgressRecruit'; | ||
|
||
interface patchSeasonProps { | ||
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. 앞글자 대문자로 맞추면 좋을 것 같아요~ |
||
newSeason: string; | ||
id: string; | ||
} | ||
|
||
const patchSeason = ({ newSeason, id }: patchSeasonProps) => { | ||
return http.patch<ProgressRecruitType>({ | ||
url: `/recruits/${id}/season`, | ||
data: { | ||
season: newSeason, | ||
}, | ||
}); | ||
}; | ||
|
||
export const usePatchSeason = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ newSeason, id }: patchSeasonProps) => { | ||
const res = await patchSeason({ newSeason, id }); | ||
|
||
return res.data; | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['get-recruit-by-id'] }); | ||
}, | ||
}); | ||
}; |
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 { ProgressRecruitType } from './useGetProgressRecruit'; | ||
|
||
interface patchSiteProps { | ||
newSiteUrl: string; | ||
id: string; | ||
} | ||
|
||
const patchSiteUrl = ({ newSiteUrl, id }: patchSiteProps) => { | ||
return http.patch<ProgressRecruitType>({ | ||
url: `/recruits/${id}/siteUrl`, | ||
data: { | ||
siteUrl: newSiteUrl, | ||
}, | ||
}); | ||
}; | ||
|
||
export const usePatchSiteUrl = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ newSiteUrl, id }: patchSiteProps) => { | ||
const res = await patchSiteUrl({ newSiteUrl, id }); | ||
|
||
return res.data; | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['get-recruit-by-id'] }); | ||
}, | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
interface PatchStatusResponse { | ||
status: string; | ||
} | ||
|
||
interface patchStatusProps { | ||
newStatus: string; | ||
id: string; | ||
} | ||
|
||
const patchStatus = ({ newStatus, id }: patchStatusProps) => { | ||
return http.patch<PatchStatusResponse>({ | ||
url: `/recruits/${id}/status`, | ||
data: { | ||
recruitStatus: newStatus, | ||
}, | ||
}); | ||
}; | ||
|
||
export const usePatchStatus = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ newStatus, id }: patchStatusProps) => { | ||
const res = await patchStatus({ newStatus, id }); | ||
|
||
console.log(res); | ||
|
||
return res.data; | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['get-recruit-by-id'] }); | ||
}, | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { http } from '@/apis/http'; | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
interface PatchTitleResponse { | ||
title: string; | ||
} | ||
|
||
interface patchTitleProps { | ||
newTitle: string; | ||
id: string; | ||
} | ||
|
||
const patchTitle = ({ newTitle, id }: patchTitleProps) => { | ||
return http.patch<PatchTitleResponse>({ | ||
url: `/recruits/${id}/title`, | ||
data: { | ||
title: newTitle, | ||
}, | ||
}); | ||
}; | ||
|
||
export const usePatchTitle = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
return useMutation({ | ||
mutationFn: async ({ newTitle, id }: patchTitleProps) => { | ||
const res = await patchTitle({ newTitle, id }); | ||
|
||
return res.data; | ||
}, | ||
onSuccess: () => { | ||
queryClient.invalidateQueries({ queryKey: ['get-recruit-by-id'] }); | ||
}, | ||
}); | ||
}; |
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.
recruit를 삭제하는데 info-card 관련 데이터들을 invalidate 하는 동작이 맞나요!?