File tree Expand file tree Collapse file tree 4 files changed +32
-9
lines changed
Expand file tree Collapse file tree 4 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -82,11 +82,11 @@ const DiaryDetailPage = ({ params: { id } }: { params: { id: number } }) => {
8282 < h5 className = "text-end text-body-4 text-gr-500" >
8383 { diaryDetail ?. memberNickname } • { diaryDetail ?. caredTime }
8484 </ h5 >
85- < div className = "flex h-[300px] w-full" >
86- { diaryDetail ?. images && (
85+ { diaryDetail ?. images . length > 0 && (
86+ < div className = "flex h-[300px] w-full" >
8787 < Carousel images = { diaryDetail ?. images } style = "rounded-16" />
88- ) }
89- </ div >
88+ </ div >
89+ ) }
9090 < h4 className = "w-full whitespace-pre-line text-body-3 text-gr-black" >
9191 { diaryDetail ?. content }
9292 </ h4 >
Original file line number Diff line number Diff line change @@ -104,9 +104,17 @@ const ZipDiaryPage = ({ params: { id } }: { params: { id: number } }) => {
104104 heightPercent = { [ '50%' , '40%' ] }
105105 name = { catDetail ?. name }
106106 memberId = { catDetail ?. id }
107- onDelete = { ( ) => {
108- deleteCat ( catDetail ?. id ) ;
109- location . href = '/zip' ;
107+ onDelete = { async ( ) => {
108+ try {
109+ await deleteCat ( catDetail ?. id ) ;
110+ toast ( { description : '삭제되었습니다.' , duration : 1000 } ) ;
111+ router . replace ( '/zip' ) ;
112+ } catch ( e ) {
113+ toast ( {
114+ description : '삭제에 실패했습니다. 잠시 후 다시 시도해주세요.' ,
115+ duration : 1500
116+ } ) ;
117+ }
110118 } }
111119 onEdit = { ( ) => {
112120 router . push ( `/zip/${ id } /edit?catId=${ catDetail ?. id } ` ) ;
Original file line number Diff line number Diff line change @@ -260,8 +260,11 @@ const DiaryWriteModal = ({
260260 const editDiaryMutation = useMutation ( {
261261 mutationFn : ( reqObj : { id : number ; diary : DiaryRegisterReqObj } ) =>
262262 editDiaryOnServer ( reqObj ) ,
263- onSuccess : ( ) => {
263+ onSuccess : async ( ) => {
264264 queryClient . invalidateQueries ( { queryKey : [ 'diaryDetail' ] } ) ;
265+ queryClient . invalidateQueries ( {
266+ predicate : q => q . queryKey [ 0 ] === 'diaries'
267+ } ) ;
265268 toast ( {
266269 description : '일지가 성공적으로 수정되었습니다.'
267270 } ) ;
Original file line number Diff line number Diff line change @@ -341,7 +341,19 @@ export const deleteCat = async (id: number) => {
341341
342342 try {
343343 const response = await fetchAuth ( `/cats/${ id } ` , requestOptions ) ;
344- return response . body ;
344+ if ( ! response . ok ) {
345+ const msg = await ( async ( ) => {
346+ try {
347+ const body = await response . text ( ) ;
348+ return body || '요청 실패' ;
349+ } catch {
350+ return '요청 실패' ;
351+ }
352+ } ) ( ) ;
353+
354+ throw new Error ( msg ) ;
355+ }
356+ return true ;
345357 } catch ( error ) {
346358 console . error ( error ) ;
347359 if ( error instanceof Error ) {
You can’t perform that action at this time.
0 commit comments