From 4742184bc68b059ec2b5e3b09a39a564b91fd0e7 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:44:47 +0900 Subject: [PATCH 01/17] feat : vi command apiCall --- source/Search.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/Search.js b/source/Search.js index 46f5285..64958bd 100644 --- a/source/Search.js +++ b/source/Search.js @@ -3,8 +3,9 @@ import {Text, Box, useInput} from 'ink'; import TextInput from 'ink-text-input'; import data from './examples/location.js'; import theme from './Theme.js'; +import {getSinglePlaceCheck} from './api/remote.js'; -const Search = ({setlist, setStation, setId, setStoreName}) => { +const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { const [search, setSearch] = useState(''); const [isHelpOn, setIsHelpOn] = useState(false); useInput((input, key) => { @@ -27,6 +28,9 @@ const Search = ({setlist, setStation, setId, setStoreName}) => { let storeId = search.slice(3, search.length); setlist(list => [...list, [[], search]]); setId(storeId); // 지금은 임시로 Id값을 저장하지만, 나중에 서버 구축이 되면, 여기서 api call 해서 가게 상세정보를 state값에 저장한다. + getSinglePlaceCheck(storeId).then(res => { + setSingleShop(res.data.body); + }); setSearch(''); return; } From a466e7977a8ec217ee5e45fe85671d6d15e7da3c Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:45:14 +0900 Subject: [PATCH 02/17] feat : cd command apiCall --- source/StationDetailType.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/source/StationDetailType.js b/source/StationDetailType.js index 3a4c920..1ebbecd 100644 --- a/source/StationDetailType.js +++ b/source/StationDetailType.js @@ -2,8 +2,15 @@ import React, {useState} from 'react'; import {Text, Box, useInput, Newline} from 'ink'; import shoplist from './examples/shoplist.js'; import theme from './Theme.js'; +import {getAllPlaceCheck} from './api/remote.js'; -const StationDetailType = ({setType, station, setlist, setStation}) => { +const StationDetailType = ({ + setType, + station, + setShops, + setlist, + setStation, +}) => { const [num, setNum] = useState(1); useInput((input, key) => { @@ -23,20 +30,20 @@ const StationDetailType = ({setType, station, setlist, setStation}) => { if (num === 1) { setType('맛집'); setlist(list => [...list, [[], `${station} 맛집`]]); - setStation(''); } else if (num === 2) { setType('카페'); setlist(list => [...list, [[], `${station} 카페`]]); - setStation(''); } else if (num === 3) { setType('액티비티'); setlist(list => [...list, [[], `${station} 액티비티`]]); - setStation(''); } else if (num === 4) { setType('술집'); setlist(list => [...list, [[], `${station} 술집`]]); - setStation(''); } + getAllPlaceCheck(1, station).then(res => { + setShops(res.data.body); // shoplist.slice(first, last) + }); + setStation(''); } }); return ( From b66726f2c9756af2e59d394ba6d2a4277c3d5f52 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:45:52 +0900 Subject: [PATCH 03/17] fix : json structure --- source/component/EachShop.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/component/EachShop.js b/source/component/EachShop.js index 0c7e429..4502452 100644 --- a/source/component/EachShop.js +++ b/source/component/EachShop.js @@ -12,7 +12,7 @@ const EachShop = ({data, key}) => { - "title" : "{data.title}", + "name" : "{data.name}", @@ -20,16 +20,16 @@ const EachShop = ({data, key}) => { - "nearStation" : "{data.nearStation}", + "storeUrl" : "{data.url}", "menu" : {'['} {data.menu.map((item, index, array) => ( - + {' '} - {'{'} "{item.name}" : {item.price} {'}'} + {'{'} "{item.menuName}" : {item.menuPrice} {'}'} {index !== array.length - 1 ? ',' : ''} @@ -38,7 +38,7 @@ const EachShop = ({data, key}) => { - "starRate" : "{data.starRate}", + "starRate" : "{data.averageStar}", From 003d6a7601441aca426801cb07b24007aaf2da95 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:46:38 +0900 Subject: [PATCH 04/17] feat : shopDetail component --- source/component/ShopDetail.js | 151 +++++++++------------------------ 1 file changed, 41 insertions(+), 110 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index 74f1eca..1454ce3 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -1,48 +1,28 @@ import React, {useState} from 'react'; -import {Text, Newline, Box, useInput, Spacer} from 'ink'; +import {Text, Newline, Box, Spacer} from 'ink'; import TextInput from 'ink-text-input'; import theme from '../Theme.js'; +import SingleShop from './SingleShop.js'; -/** - * - * @param {Object} data - * @description - * data = { - * id: '1', - * title: 'The 5th Wave', - * location: '서울시 동작구 상도로 369', - * nearStation: '상도역', - * openTime: '09:00', - * closeTime: '22:00', - * menu: [ - * { - * name: '카페라떼', - * price: 4000, - * }, - * ], - * starRate: 4.5, - * reviews: [], - * } - */ -const ShopDetail = ({Id, setId}) => { - const data = { - id: '1', - title: 'The 5th Wave', - location: '서울시 동작구 상도로 369', - nearStation: '상도역', - openTime: '09:00', - closeTime: '22:00', - menu: [ - { - name: '카페라떼', - price: 4000, - }, - ], - starRate: 4.5, - reviews: [], - }; +const ShopDetail = ({singleShop, setId}) => { + // const data = { + // id: '1', + // title: 'The 5th Wave', + // location: '서울시 동작구 상도로 369', + // nearStation: '상도역', + // openTime: '09:00', + // closeTime: '22:00', + // menu: [ + // { + // name: '카페라떼', + // price: 4000, + // }, + // ], + // starRate: 4.5, + // reviews: [], + // }; - const starRateRounded = Math.round(data.starRate); + const starRateRounded = Math.round(singleShop.averageStar); const starRateString = '⭐'.repeat(starRateRounded); @@ -65,78 +45,29 @@ const ShopDetail = ({Id, setId}) => { }; return ( - <> - {'{'} - - - - "id" : "{data.id}", - - - - "title" : "{data.title}", - - - - "location" : "{data.location}", - - - - "nearStation" : "{data.nearStation}", - - - - "openTime" : "{data.openTime}" - "{data.closeTime}", - - - - "menu" : {'['} - - {data.menu.map((item, index, array) => ( - - {' '} - {'{'} "{item.name}" : {item.price} {'}'} - {index !== array.length - 1 ? ',' : ''} - - - ))} - {']'}, - - - - "starRate" : "{starRateString}({data.starRate})", - - - - "reviews" : {'['} - {data.reviews.length == !0 ? : <>} - {data.reviews.map((item, index, array) => ( - - {' '} - {'{'} "{item.writer}" : "{item.content} ({item.starRate})" {'}'} - {index !== array.length - 1 ? ',' : ''} - - - ))} - {']'} - - - - {'}'} - Commands - - :q - quit - - :lm - load more reviews + + + + - :ar - add review + + + Commands + + + :q - quit + + :lm - load more reviews + + :ar - add review + + - - + ); }; export default ShopDetail; From 87a5a2f94b135671676fa1a3243be3202ba005e5 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:46:51 +0900 Subject: [PATCH 05/17] feat : singleShop component --- source/component/SingleShop.js | 59 ++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 source/component/SingleShop.js diff --git a/source/component/SingleShop.js b/source/component/SingleShop.js new file mode 100644 index 0000000..36561e6 --- /dev/null +++ b/source/component/SingleShop.js @@ -0,0 +1,59 @@ +import React from 'react'; +import {Text, Box, Newline} from 'ink'; + +const SingleShop = ({starRateString, data}) => { + return ( + + {'{'} + + + + "id" : "{data.id}", + + + + "name" : "{data.name}", + + + + "location" : "{data.location}", + + + + "location" : "{data.location}", + + + + "phoneNumber" : "{data.phoneNumber}", + + + + "storeUrl" : "{data.url}", + + + {/* + "menu" : {'['} + + {data.menu.map((item, index, array) => ( + + {' '} + {'{'} "{item.menuName}" : {item.menuPrice} {'}'} + {index !== array.length - 1 ? ',' : ''} + + + ))} + {']'}, + + */} + + "starRate" : "{starRateString}({data.averageStar})", + + + + + {'}'} + + ); +}; + +export default SingleShop; From 1f212fcf0f5c0947ab92c318a9f72394030de4fd Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:47:03 +0900 Subject: [PATCH 06/17] feat : apiCall --- source/api/remote.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 source/api/remote.js diff --git a/source/api/remote.js b/source/api/remote.js new file mode 100644 index 0000000..133af0c --- /dev/null +++ b/source/api/remote.js @@ -0,0 +1,12 @@ +import axios from 'axios'; + +const UpdateAxios = axios.create({ + baseURL: 'https://3v0x65nkk8.execute-api.ap-northeast-2.amazonaws.com', +}); + +const getAllPlaceCheck = (page, station) => + UpdateAxios.get(`/place?page=${page}&order=STAR&store=&station=${station}`); + +const getSinglePlaceCheck = placeId => UpdateAxios.get(`/place/${placeId}`); + +export {getAllPlaceCheck, getSinglePlaceCheck}; From 64e4716cef8eed078ef2d609c5c52f02de50c445 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:47:20 +0900 Subject: [PATCH 07/17] feat : cd command --- source/component/ListShop.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/source/component/ListShop.js b/source/component/ListShop.js index 4ce527c..de56ec7 100644 --- a/source/component/ListShop.js +++ b/source/component/ListShop.js @@ -1,19 +1,17 @@ -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {Text, Box, Newline, Spacer} from 'ink'; import theme from '../Theme.js'; import TextInput from 'ink-text-input'; import EachShop from './EachShop.js'; -import shoplist from '../examples/shoplist.js'; -const ListShop = ({setType}) => { +const ListShop = ({shops, setShops, setType}) => { let first = 0; let last = 3; const [confirmCommand, setConfirmCommand] = useState(''); - const [shops, setShops] = useState(shoplist.slice(first, last)); - const loadMore = () => { setShops([...shops, ...shoplist.slice(first + 3, last + 3)]); }; + return ( {shops.map((data, key) => ( From e6954c51fc7e3829eb7acef0bbeef797a0f296fe Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 14:47:44 +0900 Subject: [PATCH 08/17] fix : searchContainer --- source/SearchContainer.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/SearchContainer.js b/source/SearchContainer.js index 7463b67..60d5539 100644 --- a/source/SearchContainer.js +++ b/source/SearchContainer.js @@ -13,6 +13,8 @@ const SearchContainer = () => { const [Id, setId] = useState(0); const [storeName, setStoreName] = useState(''); const [type, setType] = useState(''); + const [shops, setShops] = useState([]); + const [singleShop, setSingleShop] = useState({}); return ( @@ -28,13 +30,14 @@ const SearchContainer = () => { ) : type ? ( - + ) : Id ? ( - // 여기로 ID(나중엔 상세정보) 보내고, vi 탈출할때, setId값 초기화하면, 다시 커맨드 입력 창 나옴. + // 여기로 ID(나중엔 상세정보) 보내고, vi 탈출할때, setId값 초기화하면, 다시 커맨드 입력 창 나옴. ) : storeName ? ( ) : ( @@ -43,6 +46,7 @@ const SearchContainer = () => { setStation={setStation} setId={setId} setStoreName={setStoreName} + setSingleShop={setSingleShop} /> )} From 851a38fd39486980ef67f7084ea35f94bbbe52b3 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 15:44:11 +0900 Subject: [PATCH 09/17] feat : change point of call --- source/Search.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/Search.js b/source/Search.js index a837faf..4e31cec 100644 --- a/source/Search.js +++ b/source/Search.js @@ -74,9 +74,10 @@ const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { if (search.startsWith('vi ')) { let storeId = search.slice(3, search.length); setlist(list => [...list, [[], search]]); - setId(storeId); // 지금은 임시로 Id값을 저장하지만, 나중에 서버 구축이 되면, 여기서 api call 해서 가게 상세정보를 state값에 저장한다. + // 지금은 임시로 Id값을 저장하지만, 나중에 서버 구축이 되면, 여기서 api call 해서 가게 상세정보를 state값에 저장한다. getSinglePlaceCheck(storeId).then(res => { setSingleShop(res.data.body); + setId(storeId); }); setSearch(''); return; From 890ffaab6e01a0395d644417e9def596ba5edbb9 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 15:44:24 +0900 Subject: [PATCH 10/17] fuix : shopdetail --- source/component/ShopDetail.js | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index c5033b9..0384cb0 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -1,11 +1,10 @@ import React, {useState} from 'react'; -import {Text, Newline, Box, Spacer} from 'ink'; +import {Text, Newline, Box, Spacer, useInput} from 'ink'; import TextInput from 'ink-text-input'; import theme from '../Theme.js'; import SingleShop from './SingleShop.js'; - -const ShopDetail = ({id, setId, userId,singleShop}) => { +const ShopDetail = ({id, setId, userId, singleShop}) => { const initialData = { id: '1', title: 'The 5th Wave', @@ -26,7 +25,7 @@ const ShopDetail = ({id, setId, userId,singleShop}) => { ], }; - const [data, setData] = useState(initialData); + const [data, setData] = useState(singleShop); const [command, setCommand] = useState(''); @@ -88,7 +87,6 @@ const ShopDetail = ({id, setId, userId,singleShop}) => { }; return ( - <> {!isAddReview ? ( <> @@ -138,7 +136,7 @@ const ShopDetail = ({id, setId, userId,singleShop}) => { }; const ShopView = ({data}) => { - const starRateString = '⭐'.repeat(Math.round(data.starRate)); + const starRateString = '⭐'.repeat(Math.round(data.averageStar)); return ( <> @@ -148,20 +146,20 @@ const ShopView = ({data}) => { "id" : "{data.id}", - "title" : "{data.title}", + "name" : "{data.name}", "location" : "{data.location}", - "nearStation" : "{data.nearStation}", + "nearStation" : "{data.station}", - "openTime" : "{data.openTime}" - "{data.closeTime}", + "openTime" : "{data.open_time}" - "{data.end_time}", - + {/* "menu" : {'['} @@ -175,13 +173,13 @@ const ShopView = ({data}) => { ))} {']'}, - + */} - "starRate" : "{starRateString}({data.starRate})", + "starRate" : "{starRateString}({data.averageStar})", - {data.reviews.length > 0 ? ( + {/* {data.reviews.length > 0 ? ( "reviews" : {'['} @@ -204,7 +202,7 @@ const ShopView = ({data}) => { "reviews" : {'[]'} - )} + )} */} {'}'} From bc3b7c9318802aa12308b4b7417db33d0cd53520 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:02:44 +0900 Subject: [PATCH 11/17] feat : getReviewCheck API call --- source/Search.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/Search.js b/source/Search.js index 4e31cec..9c7f096 100644 --- a/source/Search.js +++ b/source/Search.js @@ -3,7 +3,7 @@ import {Text, Box, useInput} from 'ink'; import TextInput from 'ink-text-input'; import data from './examples/location.js'; import theme from './Theme.js'; -import {getSinglePlaceCheck} from './api/remote.js'; +import {getSinglePlaceCheck, getReviewCheck} from './api/remote.js'; const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { const [search, setSearch] = useState(''); @@ -77,7 +77,10 @@ const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { // 지금은 임시로 Id값을 저장하지만, 나중에 서버 구축이 되면, 여기서 api call 해서 가게 상세정보를 state값에 저장한다. getSinglePlaceCheck(storeId).then(res => { setSingleShop(res.data.body); - setId(storeId); + getReviewCheck(storeId).then(res => { + setSingleShop(data => ({...data, reviews: res.data.body})); + setId(storeId); + }); }); setSearch(''); return; From 9d3de969b9a207245269308210468739d242fd6a Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:02:55 +0900 Subject: [PATCH 12/17] feat : getReviewCheck --- source/api/remote.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/api/remote.js b/source/api/remote.js index 133af0c..298fc04 100644 --- a/source/api/remote.js +++ b/source/api/remote.js @@ -9,4 +9,7 @@ const getAllPlaceCheck = (page, station) => const getSinglePlaceCheck = placeId => UpdateAxios.get(`/place/${placeId}`); -export {getAllPlaceCheck, getSinglePlaceCheck}; +const getReviewCheck = placeId => + UpdateAxios.get(`/review/place/${placeId}?page=1`); + +export {getAllPlaceCheck, getSinglePlaceCheck, getReviewCheck}; From 39bd7e0494b1d71613243970fc71398b5ef822ba Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:03:14 +0900 Subject: [PATCH 13/17] feat : reviewView --- source/component/ShopDetail.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index 0384cb0..981e2a4 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -179,7 +179,7 @@ const ShopView = ({data}) => { "starRate" : "{starRateString}({data.averageStar})", - {/* {data.reviews.length > 0 ? ( + {data.reviews.length > 0 ? ( "reviews" : {'['} @@ -187,9 +187,9 @@ const ShopView = ({data}) => { {data.reviews.map((item, index) => ( ))} @@ -202,7 +202,7 @@ const ShopView = ({data}) => { "reviews" : {'[]'} - )} */} + )} {'}'} From 522219faef221b6886fb7cb44d9273ec826f8a73 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:05:25 +0900 Subject: [PATCH 14/17] feat : menuView --- source/component/ShopDetail.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/component/ShopDetail.js b/source/component/ShopDetail.js index 981e2a4..25e8b7f 100644 --- a/source/component/ShopDetail.js +++ b/source/component/ShopDetail.js @@ -159,21 +159,21 @@ const ShopView = ({data}) => { "openTime" : "{data.open_time}" - "{data.end_time}", - {/* + "menu" : {'['} {data.menu.map((item, index, array) => ( {' '} - {'{'} "{item.name}" : {item.price} {'}'} + {'{'} "{item.menuName}" : {item.menuPrice} {'}'} {index !== array.length - 1 ? ',' : ''} ))} {']'}, - */} + "starRate" : "{starRateString}({data.averageStar})", From 0282b6cd9d65725b37e8e3d497fe4b0335625674 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:12:11 +0900 Subject: [PATCH 15/17] remove : annotation --- source/Search.js | 1 - 1 file changed, 1 deletion(-) diff --git a/source/Search.js b/source/Search.js index 9c7f096..edd2500 100644 --- a/source/Search.js +++ b/source/Search.js @@ -74,7 +74,6 @@ const Search = ({setlist, setStation, setId, setStoreName, setSingleShop}) => { if (search.startsWith('vi ')) { let storeId = search.slice(3, search.length); setlist(list => [...list, [[], search]]); - // 지금은 임시로 Id값을 저장하지만, 나중에 서버 구축이 되면, 여기서 api call 해서 가게 상세정보를 state값에 저장한다. getSinglePlaceCheck(storeId).then(res => { setSingleShop(res.data.body); getReviewCheck(storeId).then(res => { From 2a7894c14a9028297904299da08194bea9a6d577 Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:12:27 +0900 Subject: [PATCH 16/17] feat : formating --- source/SearchContainer.js | 7 ++++++- source/component/EachShop.js | 1 - 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/SearchContainer.js b/source/SearchContainer.js index 390d26d..7c76187 100644 --- a/source/SearchContainer.js +++ b/source/SearchContainer.js @@ -37,7 +37,12 @@ const SearchContainer = ({userId}) => { ) : type ? ( ) : id ? ( - + ) : storeName ? ( ) : ( diff --git a/source/component/EachShop.js b/source/component/EachShop.js index d54fc49..b4e6371 100644 --- a/source/component/EachShop.js +++ b/source/component/EachShop.js @@ -42,7 +42,6 @@ const EachShop = ({data, key, isEnd}) => { "starRate" : "{data.averageStar}", - {isEnd ? '}' : '},'} From 3dd868485d0891f7dcf46de75f14d965c09e07cc Mon Sep 17 00:00:00 2001 From: hoyyChoi Date: Thu, 31 Aug 2023 16:12:37 +0900 Subject: [PATCH 17/17] remove : singleShop --- source/component/SingleShop.js | 59 ---------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 source/component/SingleShop.js diff --git a/source/component/SingleShop.js b/source/component/SingleShop.js deleted file mode 100644 index 36561e6..0000000 --- a/source/component/SingleShop.js +++ /dev/null @@ -1,59 +0,0 @@ -import React from 'react'; -import {Text, Box, Newline} from 'ink'; - -const SingleShop = ({starRateString, data}) => { - return ( - - {'{'} - - - - "id" : "{data.id}", - - - - "name" : "{data.name}", - - - - "location" : "{data.location}", - - - - "location" : "{data.location}", - - - - "phoneNumber" : "{data.phoneNumber}", - - - - "storeUrl" : "{data.url}", - - - {/* - "menu" : {'['} - - {data.menu.map((item, index, array) => ( - - {' '} - {'{'} "{item.menuName}" : {item.menuPrice} {'}'} - {index !== array.length - 1 ? ',' : ''} - - - ))} - {']'}, - - */} - - "starRate" : "{starRateString}({data.averageStar})", - - - - - {'}'} - - ); -}; - -export default SingleShop;