@@ -33,6 +33,7 @@ export const __getSchedule = createAsyncThunk(
33
33
try {
34
34
console . log ( "연결" ) ;
35
35
const { data } = await ScheduleApi . getSccheduleApi ( payload ) ;
36
+ console . log ( data . data ) ;
36
37
return thunkAPI . fulfillWithValue ( data . data ) ;
37
38
} catch ( error ) {
38
39
console . log ( error ) ;
@@ -46,6 +47,7 @@ export const __getScrollPage = createAsyncThunk(
46
47
try {
47
48
console . log ( "연결" ) ;
48
49
const { data } = await ScheduleApi . getInfiniteScrollPage ( payload ) ;
50
+ console . log ( data . data ) ;
49
51
return thunkAPI . fulfillWithValue ( data ) ;
50
52
} catch ( error ) {
51
53
console . log ( error ) ;
@@ -58,23 +60,30 @@ export const __postSchedule = createAsyncThunk(
58
60
async ( payload , thunkAPI ) => {
59
61
try {
60
62
const data = await ScheduleApi . postScheduleApi ( payload . Schedule ) ;
61
- thunkAPI . dispatch ( __getSchedule ( payload . userId ) ) ;
62
- return thunkAPI . fulfillWithValue ( data . data ) ;
63
+ console . log ( payload . userId ) ;
64
+ payload . dispatch ( __getSchedule ( payload . userId ) ) ;
65
+ // return thunkAPI.fulfillWithValue(data.data);
63
66
} catch ( error ) {
64
67
return thunkAPI . rejectWithValue ( error ) ;
65
68
}
66
69
}
67
70
) ;
68
71
69
72
export const __getPastSchedlue = createAsyncThunk (
70
- "schedule/getSchedules " ,
73
+ "schedule/getPastSchedlue " ,
71
74
async ( payload , thunkAPI ) => {
72
75
try {
73
76
console . log ( "연결" ) ;
74
77
const { data } = await ScheduleApi . getPastScheduleApi ( ) ;
78
+ console . log ( data ) ;
75
79
return thunkAPI . fulfillWithValue ( data . data ) ;
76
80
} catch ( error ) {
77
- console . log ( error ) ;
81
+ console . log ( error . response . status ) ;
82
+ const errorStatus = error . response . status ;
83
+
84
+ if ( errorStatus === 500 ) {
85
+ window . alert ( "서버에 문제가 생겼습니다." ) ;
86
+ }
78
87
}
79
88
}
80
89
) ;
@@ -92,6 +101,7 @@ export const ScheduleSlice = createSlice({
92
101
state . isLoading = true ;
93
102
} ,
94
103
[ __getSchedule . fulfilled ] : ( state , action ) => {
104
+ state . isLoading = false ;
95
105
console . log ( action . payload ) ;
96
106
let schedules = action . payload ;
97
107
let tmp = 0 ;
@@ -101,13 +111,6 @@ export const ScheduleSlice = createSlice({
101
111
tmp = schedules [ i ] ;
102
112
schedules [ i ] = schedules [ j ] ;
103
113
schedules [ j ] = tmp ;
104
- // if (schedules[i].dday === 0) {
105
- // if (schedules[i].dday > schedules[j].dday) {
106
- // tmp = schedules[i];
107
- // schedules[i] = schedules[j];
108
- // schedules[j] = tmp;
109
- // }
110
- // }
111
114
}
112
115
}
113
116
}
@@ -145,27 +148,31 @@ export const ScheduleSlice = createSlice({
145
148
state . isLoading = false ;
146
149
state . error = action . payload ;
147
150
} ,
151
+
148
152
[ __getPastSchedlue . pending ] : ( state ) => {
149
153
state . isLoading = true ;
150
154
} ,
151
155
[ __getPastSchedlue . fulfilled ] : ( state , action ) => {
156
+ console . log ( action . payload ) ;
152
157
state . isLoading = false ;
153
158
state . pastSchedules = action . payload ;
154
159
} ,
160
+
155
161
[ __getPastSchedlue . rejected ] : ( state , action ) => {
156
162
state . isLoading = false ;
157
163
state . error = action . payload ;
158
164
} ,
159
- [ __deleteSchedule . pending ] : ( state ) => {
160
- state . isLoading = true ;
161
- } ,
162
- [ __deleteSchedule . fulfilled ] : ( state , action ) => {
163
- state . isLoading = false ;
164
- } ,
165
- [ __deleteSchedule . rejected ] : ( state , action ) => {
166
- state . isLoading = false ;
167
- state . error = action . error . message ;
168
- } ,
165
+
166
+ // [__deleteSchedule.pending]: (state) => {
167
+ // state.isLoading = true;
168
+ // },
169
+ // [__deleteSchedule.fulfilled]: (state, action) => {
170
+ // state.isLoading = false;
171
+ // },
172
+ // [__deleteSchedule.rejected]: (state, action) => {
173
+ // state.isLoading = false;
174
+ // state.error = action.error.message;
175
+ // },
169
176
} ,
170
177
} ) ;
171
178
0 commit comments