From 51d9df40bf5827c6dde07cbad273c169a81b2b24 Mon Sep 17 00:00:00 2001 From: sjsjmine129 Date: Sat, 1 Jun 2024 21:11:42 +0900 Subject: [PATCH] Fix/ --- src/assets/svg.js | 6 ++ src/screens/detail/ReviewWriteScreen.js | 84 ++++++++++--------------- 2 files changed, 39 insertions(+), 51 deletions(-) diff --git a/src/assets/svg.js b/src/assets/svg.js index f4d1ac1..1315ece 100644 --- a/src/assets/svg.js +++ b/src/assets/svg.js @@ -312,6 +312,12 @@ export const svgXml = { `, + reviewCamera: ` + + + + + `, phone: ` diff --git a/src/screens/detail/ReviewWriteScreen.js b/src/screens/detail/ReviewWriteScreen.js index d52ddf8..3f2a73a 100644 --- a/src/screens/detail/ReviewWriteScreen.js +++ b/src/screens/detail/ReviewWriteScreen.js @@ -57,7 +57,7 @@ export default function ReviewWriteScreen(props) { const [showRatingError, setShowRatingError] = useState(false); const [showContentError, setShowContentError] = useState(false); const [showImageError, setShowImageError] = useState(false); - const [reviewImage, setReviewImage] = useState([]); + const [reviewImage, setReviewImage] = useState(''); console.log('storeData:', 2); @@ -76,7 +76,7 @@ export default function ReviewWriteScreen(props) { `${API_URL}/v1/restaurants/${storeData.id}/reviews`, { content: reviewContent, - imageUrls: reviewImage, + imageUrls: [reviewImage], rating: rating, }, { @@ -122,10 +122,7 @@ export default function ReviewWriteScreen(props) { console.log('response image:', response.data); if (response.data.result === 'SUCCESS') { - setReviewImage(prevImages => [ - ...prevImages, - response.data.data[0].imageUrl, - ]); + setReviewImage(response.data.data[0].imageUrl); break; } count += 1; @@ -139,20 +136,6 @@ export default function ReviewWriteScreen(props) { } }; - const removeImage = index => { - setReviewImage(prevImages => prevImages.filter((_, i) => i !== index)); - }; - - const DottedLine = () => { - return ( - - {[...Array(20)].map((_, index) => ( - - ))} - - ); - }; - return ( <>
@@ -189,10 +172,10 @@ export default function ReviewWriteScreen(props) { style={styles.photoButton} onPress={() => { console.log('리뷰 사진 추가', reviewImage); - if (reviewImage.length >= 3) { - console.log('Error: Maximum 3 images allowed'); - return; - } + // if (reviewImage.) { + // console.log('Error: Maximum 3 images allowed'); + // return; + // } ImagePicker.openPicker({ width: 400, height: 400, @@ -206,8 +189,18 @@ export default function ReviewWriteScreen(props) { console.error('Image Picker Error:', error); }); }}> - - 사진 첨부하기 + {reviewImage ? ( + + + setReviewImage('')}> + X + + + ) : ( + + )} {showImageError && ( 사진은 최대 3개만 넣어주세요 @@ -225,22 +218,7 @@ export default function ReviewWriteScreen(props) { {showContentError && ( 리뷰 내용을 작성해주세요 )} - - - - {reviewImage.map((image, index) => ( - - - removeImage(index)}> - X - - - ))} - - - + @@ -267,8 +245,10 @@ const styles = StyleSheet.create({ marginVertical: 20, }, Container: { - width: '100%', + // width: '100%', marginHorizontal: 16, + justifyContent: 'center', + alignItems: 'center', }, storeName: { fontSize: 22, @@ -282,14 +262,15 @@ const styles = StyleSheet.create({ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', - backgroundColor: COLOR_WHITE, + backgroundColor: COLOR_GRAY, borderColor: COLOR_PRIMARY, borderWidth: 1, padding: 12, borderRadius: 8, marginTop: 6, - marginBottom: 16, - width: '92%', + marginBottom: 0, + width: 130, + height: 130, }, photoButtonText: { color: COLOR_PRIMARY, @@ -305,12 +286,12 @@ const styles = StyleSheet.create({ }, imageWrapper: { position: 'relative', - marginRight: 8, + // marginRight: 8, }, image: { - width: 120, - height: 120, - borderRadius: 10, + width: 130, + height: 130, + borderRadius: 8, }, removeButton: { position: 'absolute', @@ -330,7 +311,8 @@ const styles = StyleSheet.create({ borderWidth: 1, borderRadius: 8, padding: 12, - width: '92%', + // width: '92%', + // marginHorizontal: 16, height: 160, textAlignVertical: 'top', marginVertical: 16,