Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/apis/goal/useGetSimpleGoalList.ts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { axiosInstance } from '../axios';
import type { CommonResponse } from '../../types/common';
import type { SimpleGoalListDto } from '../../types/goal';
import { useQuery } from '@tanstack/react-query';
import { queryKey } from '../../constants/queryKey';

// 팀의 목표들을 간단 조회
// 이슈, 외부에서 목표 연결시 사용
const getSimpleGoalList = async (teamId: number): Promise<SimpleGoalListDto> => {
try {
const response = await axiosInstance.get<CommonResponse<SimpleGoalListDto>>(
`/api/teams/${teamId}/goals-simple`
);
if (!response.data.result) return Promise.reject(response);
return response.data.result;
} catch (error) {
console.error('팀의 목표 간단 조회 실패', error);
throw error;
}
};

export const useGetSimpleGoalList = (teamId: number) => {
return useQuery({
queryKey: [queryKey.GOAL_LIST_SIMPLE, teamId],
queryFn: () => getSimpleGoalList(teamId),
select: (data) => data.info,
});
};
28 changes: 28 additions & 0 deletions src/apis/goal/useGetTeamMemberList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { axiosInstance } from '../axios';
import type { CommonResponse } from '../../types/common';
import type { TeamMemberListDto } from '../../types/goal';
import { useQuery } from '@tanstack/react-query';
import { queryKey } from '../../constants/queryKey';

// 팀의 멤버 조회
// 목표 생성시 담당자 할당에 사용
const getTeamMemberList = async (teamId: number): Promise<TeamMemberListDto> => {
try {
const response = await axiosInstance.get<CommonResponse<TeamMemberListDto>>(
`/api/teams/${teamId}/teammate`
);
if (!response.data.result) return Promise.reject(response);
return response.data.result;
} catch (error) {
console.error('팀의 멤버 조회 실패', error);
throw error;
}
};

export const useGetTeamMemberList = (teamId: number) => {
return useQuery({
queryKey: [queryKey.TEAM_MEMBER_LIST, teamId],
queryFn: () => getTeamMemberList(teamId),
select: (data) => data.info,
});
};
28 changes: 28 additions & 0 deletions src/apis/issue/useGetSimpleIssueList.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { axiosInstance } from '../axios';
import type { CommonResponse } from '../../types/common';
import type { SimpleIssueListDto } from '../../types/issue';
import { useQuery } from '@tanstack/react-query';
import { queryKey } from '../../constants/queryKey';

// 팀의 이슈들을 간단 조회
// 이슈 연결시 사용
const getSimpleIssueList = async (teamId: number): Promise<SimpleIssueListDto> => {
try {
const response = await axiosInstance.get<CommonResponse<SimpleIssueListDto>>(
`/api/teams/${teamId}/issues-simple`
);
if (!response.data.result) return Promise.reject(response);
return response.data.result;
} catch (error) {
console.error('팀의 이슈 간단 조회 실패', error);
throw error;
}
};

export const useGetSimpleIssueList = (teamId: number) => {
return useQuery({
queryKey: [queryKey.ISSUE_LIST_SIMPLE, teamId],
queryFn: () => getSimpleIssueList(teamId),
select: (data) => data.info,
});
};
3 changes: 3 additions & 0 deletions src/constants/queryKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ export const queryKey = {
MY_PROFILE: 'my_profile',
GITHUB_LINK: 'github_link',
GOAL_LIST: 'goal_list',
GOAL_LIST_SIMPLE: 'goal_list_simple',
ISSUE_LIST: 'issue_list',
ISSUE_LIST_SIMPLE: 'issue_list_simple',
EXTERNAL_LIST: 'external_list',
NOTI_LIST: 'noti_list',
GOAL: 'goal',
EXTERNAL: 'external',
TEAM_MEMBER_LIST: 'team_member_list',
};
17 changes: 17 additions & 0 deletions src/types/goal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,20 @@ export type RequestGoalListDto = {
};

export type ResponseGoalDto = CursorBasedResponse<GoalFilter[]>;

export type SimpleGoal = Pick<Goal, 'id' | 'title'>;

export type SimpleGoalListDto = {
cnt: number;
info: SimpleGoal[];
};

export type TeamMember = {
id: number;
nickname: string;
};

export type TeamMemberListDto = {
cnt: number;
info: TeamMember[];
};
7 changes: 7 additions & 0 deletions src/types/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,10 @@ export type RequestIssueListDto = {
};

export type ResponseIssueDto = CursorBasedResponse<IssueFilter[]>;

export type SimpleIssue = Pick<Issue, 'id' | 'title'>;

export type SimpleIssueListDto = {
cnt: number;
info: SimpleIssue[];
};