Skip to content

Commit

Permalink
The input issue of Chinese word will not remove after making a chip v…
Browse files Browse the repository at this point in the history
…alue #24 (#25)
  • Loading branch information
sean1093 authored Jun 27, 2020
1 parent 6e0e302 commit 3e6565a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/src/assets/wording/search.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"title": "今晚想喝什麼",
"title": "今晚喝什麼",
"content": "輸入您喜歡的基酒,氣味,口感,體驗或是直接輸入調酒名稱,我們就會推薦您適合的調酒唷!",
"tips": "💡 溫馨小提醒:如果不知道該輸入什麼關鍵字時,可以試試我們的推薦清單",
"info_text": "🧐 輸入簡單個人資料可以讓我們搜尋更精準唷!",
Expand Down
23 changes: 15 additions & 8 deletions app/src/container/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ const DEFAULT_STATE = {
expanded: ''
};

const DEFAULT_USER_DATA_STATE = {
gender: '',
age: 1,
// helper
const findExistInTwoArray = (array1, array2) => {
for (let i = 0; i < array1.length; i += 1) {
const find = array2.findIndex(elm => elm.toLowerCase() === array1[i].toLowerCase()) > -1
if (find) return find;
}
return false;
};

const RecommendBlock = ({ dataObj, expanded, onItemSelect, onExpanded, showRecommend, onControlRecommend }) => {
Expand Down Expand Up @@ -112,7 +116,6 @@ const Card = ({ value }) => {
);
};


const Search = ({ searchPageData, getCocktailsList }) => {
const [ userAction, setUserAction] = useState(DEFAULT_STATE);

Expand All @@ -124,7 +127,8 @@ const Search = ({ searchPageData, getCocktailsList }) => {
const searchResultList = cocktailsList.filter(e => {
let filterRule = false;
for (let i = 0; i < value.length; i += 1) {
filterRule = Object.values(e.keys).indexOf(value[i]) > -1;
const keys = Object.values(e.keys);
filterRule = keys.findIndex(elm => elm.toLowerCase() == value[i].toLowerCase()) > -1
if (!filterRule) return filterRule;
}
if(signature === false) filterRule = filterRule && (e.signature === signature);
Expand All @@ -136,13 +140,15 @@ const Search = ({ searchPageData, getCocktailsList }) => {
const signature = e.target.checked;
setUserAction({ ...userAction, signature });
};
const onChipInputChange = (newValue) => {
if (value.length < 3) {
const onChipInputChange = (newValue) => {
const find = findExistInTwoArray(value, newValue);
if (value.length < 3 && !find) {
setUserAction({ ...userAction, value: [...value, ...newValue], isSearch: false });
}
};
const onSelectChange = (newValue) => {
if (value.length < 3 && value.indexOf(newValue) === -1) {
const find = findExistInTwoArray(value, [newValue]);
if (value.length < 3 && !find) {
setUserAction({ ...userAction, value: [...value, newValue], isSearch: false });
}
};
Expand Down Expand Up @@ -211,6 +217,7 @@ const Search = ({ searchPageData, getCocktailsList }) => {
label={SEARCH_TEXT.input_hint}
value={value}
fullWidth={true}
newChipKeys={[]}
onChange={(chips) => onChipInputChange(chips)}
onDelete={(chip, index) => handleDeleteChip(chip, index)}
/>
Expand Down
4 changes: 2 additions & 2 deletions app/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<meta name="google-site-verification" content="uWOWlSfcM_aXahdY732N2Fd0lIYCEXUM5K9kOm8HbFU" />
<meta name="author" content="Over Party Lab | @over.party.lab">
<meta name="keywords" content="cocktails,cocktail,調酒,調酒推薦,伏特加,琴酒,琴酒調酒,威士忌,龍舌蘭,酒,OverPartyLab,OPLab,カクテル,칵테일,OverPartyLabSignature,gin,vodka,rum,whisky,easycocktails,homebartending,homebar,makecocktails,bar,bartender,調酒教學,調酒課程,飲品,創意調酒,台北酒吧,老屋酒吧">
<meta name="description" content="今晚想喝什麼?歡迎來到 Over Party Lab 的調酒世界,只要簡單回答幾個問題,我們就會推薦適合您的調酒!來試試看吧">
<title>Over Party Lab 醉佳話。研酒室</title>
<meta name="description" content="今晚喝什麼?歡迎來到 Over Party Lab 的調酒世界,只要簡單回答幾個問題,我們就會推薦適合您的調酒!來試試看吧">
<title>Over Party Lab - 今晚喝什麼?</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
Expand Down
4 changes: 2 additions & 2 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<meta name="google-site-verification" content="uWOWlSfcM_aXahdY732N2Fd0lIYCEXUM5K9kOm8HbFU" />
<meta name="author" content="Over Party Lab | @over.party.lab">
<meta name="keywords" content="cocktails,cocktail,調酒,調酒推薦,伏特加,琴酒,琴酒調酒,威士忌,龍舌蘭,酒,OverPartyLab,OPLab,カクテル,칵테일,OverPartyLabSignature,gin,vodka,rum,whisky,easycocktails,homebartending,homebar,makecocktails,bar,bartender,調酒教學,調酒課程,飲品,創意調酒,台北酒吧,老屋酒吧">
<meta name="description" content="今晚想喝什麼?歡迎來到 Over Party Lab 的調酒世界,只要簡單回答幾個問題,我們就會推薦適合您的調酒!來試試看吧">
<title>Over Party Lab 醉佳話。研酒室</title>
<meta name="description" content="今晚喝什麼?歡迎來到 Over Party Lab 的調酒世界,只要簡單回答幾個問題,我們就會推薦適合您的調酒!來試試看吧">
<title>Over Party Lab - 今晚喝什麼?</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
Expand Down
14 changes: 7 additions & 7 deletions public/main.js

Large diffs are not rendered by default.

0 comments on commit 3e6565a

Please sign in to comment.