-
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
Showing
39 changed files
with
2,041 additions
and
63 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 |
---|---|---|
|
@@ -31,6 +31,7 @@ yarn-error.log* | |
|
||
# local env files | ||
.env*.local | ||
.env | ||
|
||
# vercel | ||
.vercel | ||
|
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,16 @@ | ||
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, | ||
}); | ||
}; |
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,21 @@ | ||
import { http } from '@/apis/http'; | ||
import { TagType } from '@/types'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
const getAllTags = () => { | ||
return http.get<TagType[]>({ | ||
url: `/tags`, | ||
}); | ||
}; | ||
|
||
export function useGetAllTags() { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-all-tags'], | ||
queryFn: async () => { | ||
const res = await getAllTags(); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
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'; | ||
|
||
type getCardCountType = Record<'서류_준비' | '과제_준비' | '인터뷰_준비', number>; | ||
|
||
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: async () => { | ||
const res = await getCardCount(id); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
35 changes: 35 additions & 0 deletions
35
src/app/(sidebar)/my-recruit/[id]/api/useGetProgressRecruit.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,35 @@ | ||
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: async () => { | ||
const res = await getProgressRecruit(); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/app/(sidebar)/my-recruit/[id]/api/useGetRecruitById.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,28 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
interface recruitByIdType { | ||
id: number; | ||
title: string; | ||
season: string; | ||
siteUrl: string; | ||
recruitStatus: string; | ||
} | ||
|
||
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: async () => { | ||
const res = await getRecruitById(id); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
28 changes: 28 additions & 0 deletions
28
src/app/(sidebar)/my-recruit/[id]/api/useGetRecruitCards.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,28 @@ | ||
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[]; | ||
}; | ||
|
||
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: async () => { | ||
const res = await getRecruitCards({ id, progress }); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
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,24 @@ | ||
import { http } from '@/apis/http'; | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
export interface SeasonType { | ||
name: string; | ||
} | ||
|
||
const getSeasons = () => { | ||
return http.get<SeasonType[]>({ | ||
url: `/seasons`, | ||
}); | ||
}; | ||
|
||
export function useGetSeasons() { | ||
const result = useSuspenseQuery({ | ||
queryKey: ['get-seasons'], | ||
queryFn: async () => { | ||
const res = await getSeasons(); | ||
return res.data; | ||
}, | ||
}); | ||
|
||
return result; | ||
} |
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 { ProgressRecruitType } from './useGetProgressRecruit'; | ||
|
||
interface PatchSeasonProps { | ||
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'] }); | ||
}, | ||
}); | ||
}; |
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 { 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'] }); | ||
}, | ||
}); | ||
}; |
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,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'] }); | ||
}, | ||
}); | ||
}; |
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,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'] }); | ||
}, | ||
}); | ||
}; |
Oops, something went wrong.