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",
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 ? ( // 타이핑된 역의 이름이 없을 경우, 입력 창 유지, 입력했을시, 맛집, 액티비티, 선택창 나옴.
{
if (res.data['statusCode'] == 404) {
setShops([]);
+ setStation('');
} else {
setShops(res.data.body);
+ setStation('');
}
});
- setStation('');
}
});
return (
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,
};
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 ? ',' : ''}
+
+
+ ))
+ ) : (
+ 메뉴가 없습니다.
+ )}
{']'},
diff --git a/source/component/ListShop.js b/source/component/ListShop.js
index fd7efef..a40a5e1 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,16 +29,21 @@ const ListShop = ({shops, setShops, setType}) => {
{'['}
- {shops.map((data, index) => (
-
- ))}
+ {shop.length !== 0 ? (
+ shop.map((data, index) => (
+
+ ))
+ ) : (
+ 리스트가 없습니다.
+ )}
{']'}
)}
-
+
+ {endMessage ? '더 이상 불러올 리스트가 없습니다' : ''}
+
-
Commands
@@ -42,7 +51,7 @@ const ListShop = ({shops, setShops, setType}) => {
:q - quit
/
- :lm - load more reviews
+ :lm - load more store
{
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('');
@@ -23,16 +25,10 @@ const ShopDetail = ({id, setId, userId, singleShop}) => {
setIsAddReview(true);
}
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),
+ ]);
}
// handle invalid command
setCommand('');
@@ -50,16 +46,25 @@ const ShopDetail = ({id, setId, userId, singleShop}) => {
const onReivewSubmit = () => {
// TODO : add review
- const updatedReviews = [
- ...data.reviews,
+
+ postReview(userId, id, content, star);
+ // 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);
@@ -69,7 +74,11 @@ const ShopDetail = ({id, setId, userId, singleShop}) => {
<>
{!isAddReview ? (
<>
-
+
Commands
:q - quit
@@ -114,7 +123,7 @@ const ShopDetail = ({id, setId, userId, singleShop}) => {
);
};
-const ShopView = ({data}) => {
+const ShopView = ({data, reviewlist, endMessage}) => {
const starRateString = '⭐'.repeat(Math.round(data.averageStar));
return (
@@ -158,18 +167,18 @@ const ShopView = ({data}) => {
"starRate" : "{starRateString} ({data.averageStar})",
- {data.reviews.length > 0 ? (
+ {reviewlist.length > 0 ? (
"reviews" : {'['}
- {data.reviews.map((item, index) => (
+ {reviewlist.map((item, index) => (
))}
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) {