@@ -8,9 +8,11 @@ import {
88 quickSaveYoutubeContent ,
99 updateContent ,
1010} from "@/services/content" ;
11- import { successToast } from "@linkyboard/components" ;
11+ import { infoToast , successToast } from "@linkyboard/components" ;
1212import { useMutation } from "@tanstack/react-query" ;
1313
14+ import type { HTTPError } from "ky" ;
15+
1416import { invalidateQueries } from ".." ;
1517
1618export const useQuickSaveContent = ( ) => {
@@ -22,8 +24,10 @@ export const useQuickSaveContent = () => {
2224 invalidateQueries ( [ CONTENT . GET_ALL_CONTENTS ] ) ;
2325 }
2426 } ,
25- onError : ( error ) => {
26- console . error ( error ) ;
27+ onError : ( error : HTTPError ) => {
28+ if ( error . response . status === 401 ) {
29+ infoToast ( "세션이 만료되었어요. 다시 로그인해주세요." ) ;
30+ }
2731 } ,
2832 } ) ;
2933} ;
@@ -37,23 +41,32 @@ export const useQuickSaveYoutubeContent = () => {
3741 invalidateQueries ( [ CONTENT . GET_ALL_CONTENTS ] ) ;
3842 }
3943 } ,
44+ onError : ( error : HTTPError ) => {
45+ if ( error . response . status === 401 ) {
46+ infoToast ( "세션이 만료되었어요. 다시 로그인해주세요." ) ;
47+ }
48+ } ,
4049 } ) ;
4150} ;
4251
4352export const useDetailSaveContent = ( ) => {
4453 return useMutation ( {
4554 mutationFn : detailSaveWebContent ,
46- onError : ( error ) => {
47- console . error ( error ) ;
55+ onError : ( error : HTTPError ) => {
56+ if ( error . response . status === 401 ) {
57+ infoToast ( "세션이 만료되었어요. 다시 로그인해주세요." ) ;
58+ }
4859 } ,
4960 } ) ;
5061} ;
5162
5263export const useDetailSaveYoutubeContent = ( ) => {
5364 return useMutation ( {
5465 mutationFn : detailSaveYoutubeContent ,
55- onError : ( error ) => {
56- console . error ( error ) ;
66+ onError : ( error : HTTPError ) => {
67+ if ( error . response . status === 401 ) {
68+ infoToast ( "세션이 만료되었어요. 다시 로그인해주세요." ) ;
69+ }
5770 } ,
5871 } ) ;
5972} ;
0 commit comments