@@ -15,10 +15,12 @@ import {
1515 useUnfollowUser ,
1616} from '@/features/profile' ;
1717import {
18+ useDeleteSharedPost ,
1819 useScrapSharedPost ,
1920 useSharedPost ,
2021 useSharedPostProps ,
2122} from '@/features/shared' ;
23+ import { useToast } from '@/features/toast' ;
2224import { getAge } from '@/shared' ;
2325
2426const styles = {
@@ -377,7 +379,14 @@ const styles = {
377379 font-weight: 600;
378380 line-height: 1.5rem;
379381 ` ,
380- modifyPostButton : styled . button `
382+ rowForDeleteAndModify : styled . div `
383+ display: flex;
384+ flex-direction: row;
385+ gap: 1rem;
386+
387+ align-self: end;
388+ ` ,
389+ postModifyButton : styled . button `
381390 all: unset;
382391 cursor: pointer;
383392
@@ -398,8 +407,28 @@ const styles = {
398407 font-style: normal;
399408 font-weight: 600;
400409 line-height: 1.5rem;
410+ ` ,
411+ postDeleteButton : styled . div `
412+ all: unset;
413+ cursor: pointer;
401414
402- align-self: end;
415+ display: flex;
416+ width: fit-content;
417+ height: fit-content;
418+ padding: 0.5rem 1.5rem;
419+ justify-content: center;
420+ align-items: center;
421+
422+ border-radius: 0.5rem;
423+ background: #e15637;
424+
425+ color: #fff;
426+ text-align: right;
427+ font-family: Pretendard;
428+ font-size: 1.125rem;
429+ font-style: normal;
430+ font-weight: 600;
431+ line-height: 1.5rem;
403432 ` ,
404433} ;
405434
@@ -410,8 +439,11 @@ export function SharedPostPage({ postId }: { postId: number }) {
410439 const mapRef = useRef < HTMLDivElement > ( null ) ;
411440
412441 const router = useRouter ( ) ;
442+ const { createToast } = useToast ( ) ;
413443 const { setStateWithPost } = useSharedPostProps ( ) ;
414444
445+ const { mutate : deleteSharedPost } = useDeleteSharedPost ( ) ;
446+
415447 const [ selected , setSelected ] = useState <
416448 | {
417449 memberId : string ;
@@ -568,14 +600,41 @@ export function SharedPostPage({ postId }: { postId: number }) {
568600 </ styles . locationInfoContainer >
569601 { sharedPost . data . publisherAccount . memberId ===
570602 auth ?. user ?. memberId && (
571- < styles . modifyPostButton
572- onClick = { ( ) => {
573- setStateWithPost ( sharedPost ) ;
574- router . push ( '/shared/writing' ) ;
575- } }
576- >
577- 수정하기
578- </ styles . modifyPostButton >
603+ < styles . rowForDeleteAndModify >
604+ < styles . postModifyButton
605+ onClick = { ( ) => {
606+ setStateWithPost ( sharedPost ) ;
607+ router . push ( '/shared/writing' ) ;
608+ } }
609+ >
610+ 수정하기
611+ </ styles . postModifyButton >
612+ < styles . postDeleteButton
613+ onClick = { ( ) => {
614+ deleteSharedPost ( postId , {
615+ onSuccess : ( ) => {
616+ createToast ( {
617+ message : '정상적으로 삭제되었습니다.' ,
618+ option : {
619+ duration : 3000 ,
620+ } ,
621+ } ) ;
622+ router . back ( ) ;
623+ } ,
624+ onError : ( ) => {
625+ createToast ( {
626+ message : '삭제하는데 실패하였습니다.' ,
627+ option : {
628+ duration : 3000 ,
629+ } ,
630+ } ) ;
631+ } ,
632+ } ) ;
633+ } }
634+ >
635+ 삭제하기
636+ </ styles . postDeleteButton >
637+ </ styles . rowForDeleteAndModify >
579638 ) }
580639 </ styles . postContainer >
581640 < styles . mateContainer >
0 commit comments