@@ -10,7 +10,7 @@ import Button from '../../components/common/Button';
1010import Modal from '../../components/Modal/Modal.jsx' ;
1111import styles from './Recipient.module.scss' ;
1212
13- export default function Recipient ( ) {
13+ export default function Recipient ( { showDelete } ) {
1414 const { id } = useParams ( ) ;
1515 const [ postData , setPostData ] = useState ( null ) ;
1616 const [ messages , setMessages ] = useState ( [ ] ) ;
@@ -107,6 +107,14 @@ export default function Recipient() {
107107 }
108108 }
109109
110+ function handleGoBack ( ) {
111+ navigate ( - 1 ) ;
112+ }
113+
114+ function handleEditClick ( id ) {
115+ navigate ( `/post/${ id } /edit` ) ;
116+ }
117+
110118 function handleOpenModal ( id ) {
111119 setSelectedCardId ( id ) ;
112120 }
@@ -126,24 +134,36 @@ export default function Recipient() {
126134 < >
127135 < HeaderService recipient = { postData } />
128136 < div
129- className = { `${ styles [ 'post-container' ] } ${ ! postData . backgroundImageURL ? styles [ `background--${ postData . backgroundColor } ` ] : '' } ` }
137+ className = { `${ styles [ 'post-container' ] } ${ ! postData . backgroundImageURL ? styles [ `background--${ postData . backgroundColor } ` ] : '' } ${ showDelete ? styles [ `background--gray` ] : '' } ` }
130138 style = {
131- postData . backgroundImageURL
139+ postData . backgroundImageURL && ! showDelete
132140 ? { backgroundImage : `url(${ postData . backgroundImageURL } )` }
133141 : { }
134142 }
135143 >
136144 < div className = { styles [ 'button-container' ] } >
137- < Button
138- className = { styles [ 'delete-button' ] }
139- type = "delete"
140- onClick = { ( ) => handleDeleteRecipient ( id ) }
141- >
142- 삭제하기
143- </ Button >
145+ < div className = { styles [ 'back-button-wrapper' ] } >
146+ < button className = { styles [ 'back-button' ] } onClick = { handleGoBack } >
147+ ← 뒤로가기
148+ </ button >
149+ </ div >
150+
151+ < div className = { styles [ 'action-button-wrapper' ] } >
152+ { showDelete ? (
153+ < Button type = "delete" onClick = { ( ) => handleDeleteRecipient ( id ) } >
154+ 페이지 삭제하기
155+ </ Button >
156+ ) : (
157+ < Button type = "delete" onClick = { ( ) => handleEditClick ( id ) } >
158+ 편집하기
159+ </ Button >
160+ ) }
161+ </ div >
144162 </ div >
145163 < div className = { styles [ 'card-container' ] } >
146- < Card recipientId = { id } empty = { true } />
164+ { ! showDelete && (
165+ < Card recipientId = { id } empty = { true } showDelete = { showDelete } />
166+ ) }
147167 { messages . map ( ( msg ) => (
148168 < Card
149169 key = { msg . id }
@@ -156,6 +176,7 @@ export default function Recipient() {
156176 onDelete = { handleDeleteMessage }
157177 onClick = { ( ) => handleOpenModal ( msg . id ) }
158178 font = { msg . font }
179+ showDelete = { showDelete }
159180 >
160181 { msg . content }
161182 </ Card >
0 commit comments