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
6- const TypeObj = {
7+ const typeObj = {
78 밀가루 : '1' ,
89 고구마 : '2' ,
910 녹차 : '3' ,
@@ -14,28 +15,32 @@ function DetailModal() {
1415 const setIsOpened = useSetRecoilState ( modalState ) ;
1516 const readingId = useRecoilValue ( idState ) ;
1617 const data = useRecoilValue ( readingDataList ) ;
18+ const [ isAlertOpend , setIsAlertOpened ] = useRecoilState ( alertState ) ;
1719 const [ backSrc , setBackSrc ] = useState ( 'background1' ) ;
1820 const [ letterSrc , setLetterSrc ] = useState ( 'letter1' ) ;
19- const { Type, message, senderNickname } = data . find ( ( e ) => e . id === readingId ) ;
21+ const { type, message, senderNickname } = data . find ( ( e ) => e . id === readingId ) ;
22+
2023 const onClickClose = ( ) => setIsOpened ( false ) ;
2124 const onClickWrapper = ( ) => setIsOpened ( false ) ;
2225
23- let [ dough , sediment ] = Type . split ( '/' ) ;
26+ let [ dough , sediment ] = type . split ( '/' ) ;
2427 const userData = JSON . parse ( localStorage . getItem ( 'user' ) ) ;
2528 const { nickname } = userData ? userData : { nickname : '익명의냥냥이' } ;
2629
27- const TypeReplace = ( ) => {
28- Object . keys ( TypeObj ) . forEach ( ( e ) => {
29- if ( e === dough ) dough = TypeObj [ e ] ;
30+ const replaceType = ( ) => {
31+ Object . keys ( typeObj ) . forEach ( ( e ) => {
32+ if ( e === dough ) dough = typeObj [ e ] ;
3033 } ) ;
3134 } ;
3235
3336 const setImageSrc = ( ) => {
34- TypeReplace ( ) ;
37+ replaceType ( ) ;
3538 setBackSrc ( `background${ dough } ` ) ;
3639 setLetterSrc ( `letter${ dough } ` ) ;
3740 } ;
3841
42+ const onClickDelete = ( ) => setIsAlertOpened ( true ) ;
43+
3944 useEffect ( ( ) => {
4045 setImageSrc ( ) ;
4146 } ) ;
@@ -50,12 +55,19 @@ function DetailModal() {
5055 < MessageContent > { message } </ MessageContent >
5156 < MessageSender > { senderNickname } </ MessageSender >
5257 </ MessageWrapper >
53- < ModalCloseButton onClick = { onClickClose } >
54- < ButtonContent > 확인 완료</ ButtonContent >
55- < ButtonBack />
56- </ 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 >
5768 </ ModalContent >
5869 </ ModalContainer >
70+ { isAlertOpend && < DetailAlert /> }
5971 </ ModalWrapper >
6072 ) ;
6173}
@@ -66,7 +78,7 @@ const ModalWrapper = styled.div`
6678 position: fixed;
6779 top: 0;
6880 left: 0;
69- width: 100vh ;
81+ width: 100% ;
7082 height: 100%;
7183 display: flex;
7284 justify-content: center;
@@ -108,7 +120,7 @@ const ModalContent = styled.div`
108120` ;
109121
110122const MessageWrapper = styled . div `
111- font-family: 'Room703 ';
123+ font-family: 'kotra ';
112124 font-weight: 400;
113125 font-size: 22px;
114126 position: relative;
@@ -154,14 +166,20 @@ const MessageSender = styled.div`
154166` ;
155167
156168const ModalCloseButton = styled . div `
157- width: calc( 100% - 28px) ;
169+ width: 100%;
158170 margin: 30px 0;
159171 height: 60px;
160172 position: relative;
161173
162174 cursor: pointer;
163175` ;
164176
177+ const ButtonWrapper = styled . div `
178+ width: 100%;
179+ display: flex;
180+ gap: 10px;
181+ ` ;
182+
165183const ButtonContent = styled . div `
166184 position: relative;
167185 z-index: 1;
@@ -175,6 +193,12 @@ const ButtonContent = styled.div`
175193 color: #fff;
176194 font-size: 20px;
177195 font-weight: 700;
196+
197+ ${ ( { type } ) =>
198+ type === 'delete' &&
199+ css `
200+ background-color: #c0c0c0;
201+ ` }
178202` ;
179203
180204const ButtonBack = styled . div `
@@ -185,4 +209,10 @@ const ButtonBack = styled.div`
185209 background-color: #813c05;
186210 border-radius: 10px;
187211 border: 2px solid #000;
212+
213+ ${ ( { type } ) =>
214+ type === 'delete' &&
215+ css `
216+ background-color: #989898;
217+ ` }
188218` ;
0 commit comments