-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/GU-99/grow-up-fe into fe…
…ature/#80-local-login
- Loading branch information
Showing
16 changed files
with
336 additions
and
66 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
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,15 @@ | ||
import axios from 'axios'; | ||
|
||
// ToDo: useAxios의 에러 처리와 react query의 에러 처리를 담당하도록 만들 것 | ||
export default function errorHandler<T extends Error>(error: T) { | ||
// ToDo: AxiosError가 아닌 경우 에러 처리 | ||
if (!axios.isAxiosError(error)) return; | ||
|
||
if (error.request) { | ||
// ToDo: 네트워크 요청을 보냈지만 응답이 없는 경우 에러 처리 | ||
} else if (error.response) { | ||
// ToDo: 요청후 응답을 받았지만 200 이외의 응답 코드인 경우 예외 처리 | ||
} else { | ||
// ToDo: request 설정 오류 | ||
} | ||
} |
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 { MutationCache, QueryCache, QueryClient } from '@tanstack/react-query'; | ||
import { MINUTE } from '@constants/units'; | ||
import errorHandler from '@hooks/errorHandler'; | ||
import type { QueryClientConfig } from '@tanstack/react-query'; | ||
|
||
// ToDo: 기본 옵션 설정 대화하고 확정하기 | ||
const queryClientOptions: QueryClientConfig = { | ||
defaultOptions: { | ||
queries: { | ||
staleTime: 5 * MINUTE, | ||
gcTime: 10 * MINUTE, | ||
refetchOnMount: true, | ||
refetchOnReconnect: true, | ||
refetchOnWindowFocus: true, | ||
retry: 3, | ||
}, | ||
}, | ||
queryCache: new QueryCache({ | ||
onError: (error) => { | ||
console.error(`Query: ${error.name}:${error.message}:${error.stack}`); | ||
errorHandler(error); | ||
}, | ||
}), | ||
mutationCache: new MutationCache({ | ||
onError: (error) => { | ||
console.error(`Mutation: ${error.name}:${error.message}:${error.stack}`); | ||
errorHandler(error); | ||
}, | ||
}), | ||
}; | ||
|
||
export const queryClient = new QueryClient(queryClientOptions); |
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 |
---|---|---|
@@ -1,20 +1,34 @@ | ||
import { TASK_DUMMY } from '@mocks/mockData'; | ||
import { TaskListWithStatus } from '@/types/TaskType'; | ||
import { Project } from '@/types/ProjectType'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { findTaskList } from '@services/taskService'; | ||
|
||
import type { TaskListWithStatus } from '@/types/TaskType'; | ||
import type { Project } from '@/types/ProjectType'; | ||
|
||
function getTaskNameList(taskList: TaskListWithStatus[]) { | ||
return taskList | ||
.map((statusTask) => statusTask.tasks) | ||
.flat() | ||
.map((task) => task.name); | ||
return taskList.length > 0 | ||
? taskList | ||
.map((statusTask) => statusTask.tasks) | ||
.flat() | ||
.map((task) => task.name) | ||
: []; | ||
} | ||
|
||
// Todo: Task Query CRUD로직 작성하기 | ||
// QueryKey: project, projectId, tasks | ||
export default function useTaskQuery(projectId: Project['projectId']) { | ||
const taskList = TASK_DUMMY; | ||
// Todo: Task Query CUD로직 작성하기 | ||
export function useTasksQuery(projectId: Project['projectId']) { | ||
const { | ||
data: taskList = [], | ||
isLoading: isTaskLoading, | ||
isError: isTaskError, | ||
error: taskError, | ||
} = useQuery({ | ||
queryKey: ['projects', projectId, 'tasks'], | ||
queryFn: async () => { | ||
const { data } = await findTaskList(projectId); | ||
return data; | ||
}, | ||
}); | ||
|
||
const taskNameList = taskList ? getTaskNameList(taskList) : []; | ||
const taskNameList = getTaskNameList(taskList); | ||
|
||
return { taskList, taskNameList }; | ||
return { taskList, taskNameList, isTaskLoading, isTaskError, taskError }; | ||
} |
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
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 |
---|---|---|
@@ -1,8 +1,15 @@ | ||
import userServiceHandler from '@mocks/services/userServiceHandler'; | ||
import teamServiceHandler from '@mocks/services/teamServiceHandler'; | ||
import projectServiceHandler from '@mocks/services/projectServiceHandler'; | ||
import taskServiceHandler from '@mocks/services/taskServiceHandler'; | ||
import authServiceHandler from './services/authServiceHandler'; | ||
|
||
const handlers = [...userServiceHandler, ...teamServiceHandler, ...projectServiceHandler, ...authServiceHandler]; | ||
const handlers = [ | ||
...userServiceHandler, | ||
...teamServiceHandler, | ||
...projectServiceHandler, | ||
...taskServiceHandler, | ||
...authServiceHandler, | ||
]; | ||
|
||
export default handlers; |
Oops, something went wrong.