File tree Expand file tree Collapse file tree 4 files changed +27
-8
lines changed
home/todoListContainer/components/cheerMessageCard Expand file tree Collapse file tree 4 files changed +27
-8
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 11'use client' ;
22
33import { EditGoalFormElement } from '@/feature/goal' ;
4- import { useMutation , useQuery , useQueryClient } from '@tanstack/react-query' ;
4+ import { useMutation , useQueryClient , useSuspenseQuery } from '@tanstack/react-query' ;
55import { GoalQuery } from '@/model/goal/queries' ;
66import { GoalQueryKeys } from '@/model/goal/queryKeys' ;
77import { Goal } from '@/shared/type/goal' ;
@@ -13,10 +13,11 @@ import { useRouter, notFound } from 'next/navigation';
1313import { ROUTES } from '@/shared/constants/routes' ;
1414
1515export 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]" >
Original file line number Diff line number Diff line change @@ -2,6 +2,11 @@ import { apiClient } from '@/shared/lib/apiClient';
22import { GrorongAdviceResponse } from './type' ;
33
44export 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}
Original file line number Diff line number Diff line change @@ -14,6 +14,11 @@ export interface AIMentorAdvice {
1414export interface AIMentorAdviceResponse extends CommonResponse < AIMentorAdvice > { }
1515
1616export 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}
You can’t perform that action at this time.
0 commit comments