Skip to content

Commit

Permalink
feat(my-recruit): 내정보뽀각 페이지 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
qkrdmstlr3 committed Aug 22, 2024
1 parent 79e6cd2 commit 22d1daf
Show file tree
Hide file tree
Showing 40 changed files with 870 additions and 409 deletions.
11 changes: 11 additions & 0 deletions .pnp.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
"react-dom": "^18",
"tailwind-merge": "^2.4.0",
"tailwind-variants": "^0.2.1",
"tailwindcss-animate": "^1.0.7"
"tailwindcss-animate": "^1.0.7",
"ts-pattern": "^5.3.1"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.6.1",
Expand Down
15 changes: 15 additions & 0 deletions src/app/(sidebar)/my-recruit/api/useDeleteRecruit.ts
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),
});
27 changes: 27 additions & 0 deletions src/app/(sidebar)/my-recruit/api/useGetAllRecruits.ts
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;
}
28 changes: 28 additions & 0 deletions src/app/(sidebar)/my-recruit/api/useGetCards.ts
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 src/app/(sidebar)/my-recruit/api/useGetProgressingRecruits.ts
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 src/app/(sidebar)/my-recruit/api/useGetRecruitsBySeason.ts
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;
}
20 changes: 20 additions & 0 deletions src/app/(sidebar)/my-recruit/api/useGetSeasons.ts
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;
}
22 changes: 22 additions & 0 deletions src/app/(sidebar)/my-recruit/api/usePatchRecruitStatus.ts
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;
}
22 changes: 22 additions & 0 deletions src/app/(sidebar)/my-recruit/api/usePostCardToRecruit.ts
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;
}
27 changes: 27 additions & 0 deletions src/app/(sidebar)/my-recruit/api/usePostRecruit.ts
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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props extends ComponentProps<'input'> {

export function InputField({ required = false, right, value, ...inputProps }: Props) {
return (
<div className="w-full flex justify-between items-center p-12 bg-neutral-1 border-neutral-20 rounded-[8px] border-[1px]">
<div className="w-full flex justify-between items-center px-16 py-12 bg-neutral-1 border-neutral-20 rounded-[8px] border-[1px]">
<If condition={required}>
<div className="text-mint-40 text-label1">*</div>
</If>
Expand Down
Loading

0 comments on commit 22d1daf

Please sign in to comment.