11import styled , { css } from 'styled-components' ;
2- import { useRecoilValue , useSetRecoilState } from 'recoil' ;
3- import { modalState , readingDataList , idState } from '../../atoms/fishBreadList' ;
2+ import { useRecoilValue , useSetRecoilState , useRecoilState } from 'recoil' ;
3+ import { modalState , readingDataList , idState , alertState } from '../ ../../atoms/fishBreadList' ;
44import { useEffect , useState } from 'react' ;
5+ import DetailAlert from './DetailAlert' ;
56
67const typeObj = {
78 밀가루 : '1' ,
@@ -14,10 +15,11 @@ function DetailModal() {
1415 const setIsOpened = useSetRecoilState ( modalState ) ;
1516 const readingId = useRecoilValue ( idState ) ;
1617 const data = useRecoilValue ( readingDataList ) ;
17- console . log ( data )
18+ const [ isAlertOpend , setIsAlertOpened ] = useRecoilState ( alertState ) ;
1819 const [ backSrc , setBackSrc ] = useState ( 'background1' ) ;
1920 const [ letterSrc , setLetterSrc ] = useState ( 'letter1' ) ;
20- const { type, message, senderNickname } = data . find ( ( e ) => e . fishId === readingId ) ;
21+ const { type, message, senderNickname } = data . find ( ( e ) => e . id === readingId ) ;
22+
2123 const onClickClose = ( ) => setIsOpened ( false ) ;
2224 const onClickWrapper = ( ) => setIsOpened ( false ) ;
2325
@@ -37,6 +39,8 @@ function DetailModal() {
3739 setLetterSrc ( `letter${ dough } ` ) ;
3840 } ;
3941
42+ const onClickDelete = ( ) => setIsAlertOpened ( true ) ;
43+
4044 useEffect ( ( ) => {
4145 setImageSrc ( ) ;
4246 } ) ;
@@ -51,12 +55,19 @@ function DetailModal() {
5155 < MessageContent > { message } </ MessageContent >
5256 < MessageSender > { senderNickname } </ MessageSender >
5357 </ MessageWrapper >
54- < ModalCloseButton onClick = { onClickClose } >
55- < ButtonContent > 확인 완료</ ButtonContent >
56- < ButtonBack />
57- </ ModalCloseButton >
58+ < ButtonWrapper >
59+ < ModalCloseButton onClick = { onClickDelete } >
60+ < ButtonContent type = "delete" > 삭제</ ButtonContent >
61+ < ButtonBack type = "delete" />
62+ </ ModalCloseButton >
63+ < ModalCloseButton onClick = { onClickClose } >
64+ < ButtonContent > 확인</ ButtonContent >
65+ < ButtonBack />
66+ </ ModalCloseButton >
67+ </ ButtonWrapper >
5868 </ ModalContent >
5969 </ ModalContainer >
70+ { isAlertOpend && < DetailAlert /> }
6071 </ ModalWrapper >
6172 ) ;
6273}
@@ -67,7 +78,7 @@ const ModalWrapper = styled.div`
6778 position: fixed;
6879 top: 0;
6980 left: 0;
70- width: 100vh ;
81+ width: 100% ;
7182 height: 100%;
7283 display: flex;
7384 justify-content: center;
@@ -155,14 +166,20 @@ const MessageSender = styled.div`
155166` ;
156167
157168const ModalCloseButton = styled . div `
158- width: calc( 100% - 28px) ;
169+ width: 100%;
159170 margin: 30px 0;
160171 height: 60px;
161172 position: relative;
162173
163174 cursor: pointer;
164175` ;
165176
177+ const ButtonWrapper = styled . div `
178+ width: 100%;
179+ display: flex;
180+ gap: 10px;
181+ ` ;
182+
166183const ButtonContent = styled . div `
167184 position: relative;
168185 z-index: 1;
@@ -176,6 +193,12 @@ const ButtonContent = styled.div`
176193 color: #fff;
177194 font-size: 20px;
178195 font-weight: 700;
196+
197+ ${ ( { type } ) =>
198+ type === 'delete' &&
199+ css `
200+ background-color: #c0c0c0;
201+ ` }
179202` ;
180203
181204const ButtonBack = styled . div `
@@ -186,4 +209,10 @@ const ButtonBack = styled.div`
186209 background-color: #813c05;
187210 border-radius: 10px;
188211 border: 2px solid #000;
212+
213+ ${ ( { type } ) =>
214+ type === 'delete' &&
215+ css `
216+ background-color: #989898;
217+ ` }
189218` ;
0 commit comments