Skip to content

Commit 0be09ea

Browse files
authored
Merge pull request #133 from vecosystem/feature/#130-team-overview-api
2 parents 492f2d4 + 862142f commit 0be09ea

6 files changed

Lines changed: 111 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { axiosInstance } from '../axios';
2+
import type { CommonResponse } from '../../types/common';
3+
import type { SimpleGoalListDto } from '../../types/goal';
4+
import { useQuery } from '@tanstack/react-query';
5+
import { queryKey } from '../../constants/queryKey';
6+
7+
// 팀의 목표들을 간단 조회
8+
// 이슈, 외부에서 목표 연결시 사용
9+
const getSimpleGoalList = async (teamId: number): Promise<SimpleGoalListDto> => {
10+
try {
11+
const response = await axiosInstance.get<CommonResponse<SimpleGoalListDto>>(
12+
`/api/teams/${teamId}/goals-simple`
13+
);
14+
if (!response.data.result) return Promise.reject(response);
15+
return response.data.result;
16+
} catch (error) {
17+
console.error('팀의 목표 간단 조회 실패', error);
18+
throw error;
19+
}
20+
};
21+
22+
export const useGetSimpleGoalList = (teamId: number) => {
23+
return useQuery({
24+
queryKey: [queryKey.GOAL_LIST_SIMPLE, teamId],
25+
queryFn: () => getSimpleGoalList(teamId),
26+
select: (data) => data.info,
27+
});
28+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { axiosInstance } from '../axios';
2+
import type { CommonResponse } from '../../types/common';
3+
import type { TeamMemberListDto } from '../../types/goal';
4+
import { useQuery } from '@tanstack/react-query';
5+
import { queryKey } from '../../constants/queryKey';
6+
7+
// 팀의 멤버 조회
8+
// 목표 생성시 담당자 할당에 사용
9+
const getTeamMemberList = async (teamId: number): Promise<TeamMemberListDto> => {
10+
try {
11+
const response = await axiosInstance.get<CommonResponse<TeamMemberListDto>>(
12+
`/api/teams/${teamId}/teammate`
13+
);
14+
if (!response.data.result) return Promise.reject(response);
15+
return response.data.result;
16+
} catch (error) {
17+
console.error('팀의 멤버 조회 실패', error);
18+
throw error;
19+
}
20+
};
21+
22+
export const useGetTeamMemberList = (teamId: number) => {
23+
return useQuery({
24+
queryKey: [queryKey.TEAM_MEMBER_LIST, teamId],
25+
queryFn: () => getTeamMemberList(teamId),
26+
select: (data) => data.info,
27+
});
28+
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { axiosInstance } from '../axios';
2+
import type { CommonResponse } from '../../types/common';
3+
import type { SimpleIssueListDto } from '../../types/issue';
4+
import { useQuery } from '@tanstack/react-query';
5+
import { queryKey } from '../../constants/queryKey';
6+
7+
// 팀의 이슈들을 간단 조회
8+
// 이슈 연결시 사용
9+
const getSimpleIssueList = async (teamId: number): Promise<SimpleIssueListDto> => {
10+
try {
11+
const response = await axiosInstance.get<CommonResponse<SimpleIssueListDto>>(
12+
`/api/teams/${teamId}/issues-simple`
13+
);
14+
if (!response.data.result) return Promise.reject(response);
15+
return response.data.result;
16+
} catch (error) {
17+
console.error('팀의 이슈 간단 조회 실패', error);
18+
throw error;
19+
}
20+
};
21+
22+
export const useGetSimpleIssueList = (teamId: number) => {
23+
return useQuery({
24+
queryKey: [queryKey.ISSUE_LIST_SIMPLE, teamId],
25+
queryFn: () => getSimpleIssueList(teamId),
26+
select: (data) => data.info,
27+
});
28+
};

src/constants/queryKey.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ export const queryKey = {
55
MY_PROFILE: 'my_profile',
66
GITHUB_LINK: 'github_link',
77
GOAL_LIST: 'goal_list',
8+
GOAL_LIST_SIMPLE: 'goal_list_simple',
89
ISSUE_LIST: 'issue_list',
10+
ISSUE_LIST_SIMPLE: 'issue_list_simple',
911
EXTERNAL_LIST: 'external_list',
1012
NOTI_LIST: 'noti_list',
1113
GOAL: 'goal',
1214
EXTERNAL: 'external',
15+
TEAM_MEMBER_LIST: 'team_member_list',
1316
};

src/types/goal.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,20 @@ export type RequestGoalListDto = {
3939
};
4040

4141
export type ResponseGoalDto = CursorBasedResponse<GoalFilter[]>;
42+
43+
export type SimpleGoal = Pick<Goal, 'id' | 'title'>;
44+
45+
export type SimpleGoalListDto = {
46+
cnt: number;
47+
info: SimpleGoal[];
48+
};
49+
50+
export type TeamMember = {
51+
id: number;
52+
nickname: string;
53+
};
54+
55+
export type TeamMemberListDto = {
56+
cnt: number;
57+
info: TeamMember[];
58+
};

src/types/issue.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,10 @@ export type RequestIssueListDto = {
4747
};
4848

4949
export type ResponseIssueDto = CursorBasedResponse<IssueFilter[]>;
50+
51+
export type SimpleIssue = Pick<Issue, 'id' | 'title'>;
52+
53+
export type SimpleIssueListDto = {
54+
cnt: number;
55+
info: SimpleIssue[];
56+
};

0 commit comments

Comments
 (0)