Skip to content

Commit 9b6a232

Browse files
authored
Merge pull request #235 from DDD-Community/fix/goal
hotfix: 목표 수정 페이지로 이동되지 않는 버그 픽스
2 parents e9699f4 + c1b2d08 commit 9b6a232

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default function GoalEditPageLoading() {
2+
return (
3+
<div className="w-full h-screen flex flex-col bg-normal items-center justify-center">
4+
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-white mx-auto mb-4" />
5+
<p className="text-gray-100 text-sm font-medium">목표 데이터를 불러오는 중입니다...</p>
6+
</div>
7+
);
8+
}

src/composite/goal/edit/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { EditGoalFormElement } from '@/feature/goal';
4-
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
4+
import { useMutation, useQueryClient, useSuspenseQuery } from '@tanstack/react-query';
55
import { GoalQuery } from '@/model/goal/queries';
66
import { GoalQueryKeys } from '@/model/goal/queryKeys';
77
import { Goal } from '@/shared/type/goal';
@@ -13,10 +13,11 @@ import { useRouter, notFound } from 'next/navigation';
1313
import { ROUTES } from '@/shared/constants/routes';
1414

1515
export default function GoalEditFormController({ goalId }: { goalId: string }) {
16-
const { data: currentGoal } = useQuery(GoalQuery.getGoalById(goalId));
16+
const { data: currentGoal, isError } = useSuspenseQuery(GoalQuery.getGoalById(goalId));
1717

18-
// 새로고침 대응을 위해 캐시가 없으면 현재 목표 패칭하는 로직 추가 예정
19-
if (!currentGoal) notFound();
18+
if (isError || !currentGoal) {
19+
notFound();
20+
}
2021

2122
return (
2223
<div className="flex flex-1 flex-col min-h-screen bg-[#1B1C1E]">

src/composite/home/todoListContainer/components/cheerMessageCard/api.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { apiClient } from '@/shared/lib/apiClient';
22
import { GrorongAdviceResponse } from './type';
33

44
export async function getGrorongAdvice() {
5-
const response = await apiClient.get<GrorongAdviceResponse>('/advice/grorong ');
6-
return response.data.data;
5+
try {
6+
const response = await apiClient.get<GrorongAdviceResponse>('/advice/grorong');
7+
return response.data.data;
8+
} catch (error) {
9+
console.error('Failed to fetch grorong advice:', error);
10+
throw new Error('그로롱 조언 조회에 실패했습니다.');
11+
}
712
}

src/model/aiMentor/api.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ export interface AIMentorAdvice {
1414
export interface AIMentorAdviceResponse extends CommonResponse<AIMentorAdvice> {}
1515

1616
export async function getAIMentorAdvice() {
17-
const response = await apiClient.get<AIMentorAdviceResponse>('/advice/mentor');
18-
return response.data.data;
17+
try {
18+
const response = await apiClient.get<AIMentorAdviceResponse>('/advice/mentor');
19+
return response.data.data;
20+
} catch (error) {
21+
console.error('Failed to fetch ai mentor advice:', error);
22+
throw new Error('AI 멘토 조언 조회에 실패했습니다.');
23+
}
1924
}

0 commit comments

Comments
 (0)