From 17bb5f41b1909c96b038d49e181cd371336dca71 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 02:52:04 +0900 Subject: [PATCH 1/8] fix : point of apiCall --- source/StationDetailType.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/StationDetailType.js b/source/StationDetailType.js index c3fa3a6..bcaf717 100644 --- a/source/StationDetailType.js +++ b/source/StationDetailType.js @@ -43,11 +43,12 @@ const StationDetailType = ({ getAllPlaceCheck(1, station).then(res => { if (res.data['statusCode'] == 404) { setShops([]); + setStation(''); } else { setShops(res.data.body); + setStation(''); } }); - setStation(''); } }); return ( From 7d35d3ed29298432d4d724d246ac599cfea26305 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 02:52:20 +0900 Subject: [PATCH 2/8] feat : postReview --- source/api/remote.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/api/remote.js b/source/api/remote.js index a605129..b9eeb2a 100644 --- a/source/api/remote.js +++ b/source/api/remote.js @@ -45,6 +45,9 @@ const postRegister = (userId, eMail) => email: eMail, }); +const postReview = (userId, placeId, content, star) => + UpdateAxios.post(`review/user/${userId}/place/${placeId}`, {content, star}); + export { getAllPlaceCheck, getSinglePlaceCheck, @@ -52,4 +55,5 @@ export { getLoginCheck, postRegister, getReviewCheck, + postReview, }; From e98d3b6071ab25fa824b09e28390c964389f1e97 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 02:53:04 +0900 Subject: [PATCH 3/8] feat : no menu, error handling --- source/component/EachShop.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/source/component/EachShop.js b/source/component/EachShop.js index 71a4235..f41b055 100644 --- a/source/component/EachShop.js +++ b/source/component/EachShop.js @@ -26,14 +26,18 @@ const EachShop = ({data, key, isEnd}) => { "menu" : {'['} - {data.menu.map((item, index, array) => ( - - {' '} - {'{'} "{item.menuName}" : {item.menuPrice} {'}'} - {index !== array.length - 1 ? ',' : ''} - - - ))} + {data.menu ? ( + data.menu.map((item, index, array) => ( + + {' '} + {'{'} "{item.menuName}" : {item.menuPrice} {'}'} + {index !== array.length - 1 ? ',' : ''} + + + )) + ) : ( + 메뉴가 없습니다. + )} {']'}, From fd4742e0f6bea198e6f728962e1bc62d69fa24ff Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 02:53:44 +0900 Subject: [PATCH 4/8] feat : :lm command (by cd 'station') --- source/component/ListShop.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/source/component/ListShop.js b/source/component/ListShop.js index fd7efef..b9f4cf5 100644 --- a/source/component/ListShop.js +++ b/source/component/ListShop.js @@ -6,17 +6,21 @@ import EachShop from './EachShop.js'; import shoplist from '../examples/shoplist.js'; const ListShop = ({shops, setShops, setType}) => { - let first = 0; - let last = 3; const [confirmCommand, setConfirmCommand] = useState(''); + const [shop, setShop] = useState(shops.slice(0, 3)); + const [endMessage, setEndMessage] = useState(false); const loadMore = () => { - setShops([...shops, ...shoplist.slice(first + 3, last + 3)]); + setShop([...shop, ...shops.slice(shop.length, shop.length + 1)]); + + if (shops.length === shop.length) { + setEndMessage(true); + } }; return ( <> - {shops.length === 0 ? ( + {shop.length === 0 ? ( Status code: 404 검색 결과가 없습니다. @@ -25,14 +29,20 @@ const ListShop = ({shops, setShops, setType}) => { {'['} - {shops.map((data, index) => ( - - ))} + {shop.length !== 0 ? ( + shop.map((data, index) => ( + + )) + ) : ( + 리스트가 없습니다. + )} {']'} )} - + + {endMessage ? '더 이상 불러올 리스트가 없습니다' : ''} + @@ -42,7 +52,7 @@ const ListShop = ({shops, setShops, setType}) => { :q - quit / - :lm - load more reviews + :lm - load more store Date: Sat, 2 Sep 2023 02:53:58 +0900 Subject: [PATCH 5/8] feat : :lm command (by vi 'id') --- source/component/ShopDetail.js | 39 ++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index c6fcae9..f12789c 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -2,12 +2,14 @@ import React, {useState} from 'react'; import {Text, Newline, Box, useInput} from 'ink'; import TextInput from 'ink-text-input'; import theme from '../Theme.js'; +import {postReview} from '../api/remote.js'; const ShopDetail = ({id, setId, userId, singleShop}) => { const [data, setData] = useState(singleShop); + const [reviewlist, setReviewlist] = useState(singleShop.reviews.slice(0, 3)); const [command, setCommand] = useState(''); - + const [endMessage, setEndMessage] = useState(false); const [isAddReview, setIsAddReview] = useState(false); const [content, setContent] = useState(''); @@ -24,15 +26,14 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { } if (command === ':lm') { // TODO : load more reviews - const updatedReviews = [ - ...data.reviews, - { - userId: 'hoyeon', - content: 'content', - star: 3, - }, - ]; - setData({...data, reviews: updatedReviews}); + setReviewlist([ + ...reviewlist, + ...singleShop.reviews.slice(reviewlist.length, reviewlist.length + 1), + ]); + + if (reviewlist.length === singleShop.reviews.length) { + setEndMessage(true); + } } // handle invalid command setCommand(''); @@ -50,6 +51,8 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { const onReivewSubmit = () => { // TODO : add review + + postReview(userId, id, content, star); const updatedReviews = [ ...data.reviews, { @@ -58,7 +61,6 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { star: star, }, ]; - setData({...data, reviews: updatedReviews}); setContent(''); setStar(5); @@ -69,7 +71,11 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { <> {!isAddReview ? ( <> - + Commands :q - quit @@ -114,7 +120,7 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { ); }; -const ShopView = ({data}) => { +const ShopView = ({data, reviewlist, endMessage}) => { const starRateString = '⭐'.repeat(Math.round(data.averageStar)); return ( @@ -158,22 +164,23 @@ const ShopView = ({data}) => { "starRate" : "{starRateString} ({data.averageStar})", - {data.reviews.length > 0 ? ( + {reviewlist.length > 0 ? ( "reviews" : {'['} - {data.reviews.map((item, index) => ( + {reviewlist.map((item, index) => ( ))} + {endMessage ? '더 이상 리뷰가 없어욧!' : ''} {']'} From e4f5b0778616b9d8277fdf4463153381b0becc01 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Sat, 2 Sep 2023 04:52:32 +0900 Subject: [PATCH 6/8] feat : Add review --- source/component/ShopDetail.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index f12789c..eec2681 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -53,15 +53,23 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { // TODO : add review postReview(userId, id, content, star); - const updatedReviews = [ - ...data.reviews, + // const updatedReviews = [ + // ...data.reviews, + // { + // userId: userId, + // content: content, + // star: star, + // }, + // ]; + // setData({...data, reviews: updatedReviews}); + setReviewlist([ + ...reviewlist, { userId: userId, content: content, star: star, }, - ]; - setData({...data, reviews: updatedReviews}); + ]); setContent(''); setStar(5); setIsAddReview(false); From f025cd5d7348e16b35db2b79235e4f47111732c2 Mon Sep 17 00:00:00 2001 From: Sanghyeon Sim <5338095@gmail.com> Date: Sat, 2 Sep 2023 08:44:58 +0900 Subject: [PATCH 7/8] fix: make output clear --- source/Output.js | 6 +++--- source/Search.js | 6 +++++- source/SearchContainer.js | 1 - source/component/ListShop.js | 1 - source/component/ShopDetail.js | 6 ------ source/component/ShopPost.js | 13 ++++++++----- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/source/Output.js b/source/Output.js index 5bbe855..e2f6d86 100644 --- a/source/Output.js +++ b/source/Output.js @@ -10,8 +10,8 @@ const Output = ({list}) => { const check = /[ㄱ-ㅎ|ㅏ-ㅣ|가-힣]/; return ( - {list.map(item => ( - <> + {list.map((item, index) => ( + $ {item[1]} {item[1] === 'ls' ? ( @@ -21,7 +21,7 @@ const Output = ({list}) => { ) : ( {item[0][0]} )} - + ))} ); diff --git a/source/Search.js b/source/Search.js index 12e870d..a515d1d 100644 --- a/source/Search.js +++ b/source/Search.js @@ -75,8 +75,12 @@ const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { } if (search.startsWith('vi ')) { let storeId = search.slice(3, search.length); - setlist(list => [...list, [[], search]]); getSinglePlaceCheck(storeId).then(res => { + if (res.data['statusCode'] == 404) { + setlist(list => [...list, [["해당하는 가게가 없습니다."], search]]); + setId(0); + return; + } setSingleShop(res.data.body); getReviewCheck(storeId).then(res => { setSingleShop(data => ({...data, reviews: res.data.body})); diff --git a/source/SearchContainer.js b/source/SearchContainer.js index 4cc20cf..88d2c84 100644 --- a/source/SearchContainer.js +++ b/source/SearchContainer.js @@ -25,7 +25,6 @@ const SearchContainer = ({userId}) => { ) /* vi 창 들어기서 Id 값 다시 초기화 해줘야함.!*/ } - {/* {aaa ? : ''} */} {station ? ( // 타이핑된 역의 이름이 없을 경우, 입력 창 유지, 입력했을시, 맛집, 액티비티, 선택창 나옴. { {endMessage ? '더 이상 불러올 리스트가 없습니다' : ''} - Commands diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index eec2681..5dd60b9 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -25,15 +25,10 @@ const ShopDetail = ({id, setId, userId, singleShop}) => { setIsAddReview(true); } if (command === ':lm') { - // TODO : load more reviews setReviewlist([ ...reviewlist, ...singleShop.reviews.slice(reviewlist.length, reviewlist.length + 1), ]); - - if (reviewlist.length === singleShop.reviews.length) { - setEndMessage(true); - } } // handle invalid command setCommand(''); @@ -188,7 +183,6 @@ const ShopView = ({data, reviewlist, endMessage}) => { ))} - {endMessage ? '더 이상 리뷰가 없어욧!' : ''} {']'} diff --git a/source/component/ShopPost.js b/source/component/ShopPost.js index 022faa7..8a25348 100644 --- a/source/component/ShopPost.js +++ b/source/component/ShopPost.js @@ -264,11 +264,14 @@ const ShopPost = ({userId, category, setStoreName}) => { // 메뉴 추가 const addMenu = () => { - setMenuList([...menuList, {name: menuName, price: menuPrice}]); - setMenuName(''); // 입력 필드 초기화 - setMenuPrice(0); // 입력 필드 초기화 - setFocus(0); // 포커스 초기화 - }; + setMenuList([ + ...menuList, + {name: menuName.split('\\')[0].trim(), price: menuPrice}, + ]); + setMenuName(''); // 입력 필드 초기화 + setMenuPrice(0); // 입력 필드 초기화 + setFocus(0); // 포커스 초기화 + }; const searchKakaoShops = async () => { if (!shopTitle.length) { From 7f11b7cb3eb0999896aa5ed83d61c2c57aecaa9c Mon Sep 17 00:00:00 2001 From: Sanghyeon Sim <5338095@gmail.com> Date: Sat, 2 Sep 2023 08:45:28 +0900 Subject: [PATCH 8/8] chore: version 0.0.14 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e003cc..e826185 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "up-d4te", - "version": "0.0.13", + "version": "0.0.14", "description": "Recommend Dating Course in Korea with CLI", "author": { "name": "Sanghyeon Sim",