File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff line change 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+ } ;
Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff line change @@ -39,3 +39,20 @@ export type RequestGoalListDto = {
3939} ;
4040
4141export 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+ } ;
Original file line number Diff line number Diff line change @@ -47,3 +47,10 @@ export type RequestIssueListDto = {
4747} ;
4848
4949export 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+ } ;
You can’t perform that action at this time.
0 commit comments