From 22afd4cf502a4dbd7bf68308cd92443545336645 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Fri, 28 Apr 2023 10:51:17 +0700 Subject: search spell when not found --- src/core/api/searchSpellApi.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/core/api/searchSpellApi.js (limited to 'src/core/api') diff --git a/src/core/api/searchSpellApi.js b/src/core/api/searchSpellApi.js new file mode 100644 index 00000000..4794c3e1 --- /dev/null +++ b/src/core/api/searchSpellApi.js @@ -0,0 +1,14 @@ +import axios from 'axios' + +const searchSpellApi = async ({ query }) => { + const dataSearchSpell = await axios( + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/spell?q=${query.trim()}` + ) + return dataSearchSpell +} + +searchSpellApi.defaultProps = { + query: '' +} + +export default searchSpellApi -- cgit v1.2.3 From 988badbf4dfd9bf493ff37fd9e5ac81ed34adb14 Mon Sep 17 00:00:00 2001 From: Rafi Zadanly Date: Tue, 2 May 2023 15:13:29 +0700 Subject: Bug fix error suggestions when search include "&" --- src/core/api/searchSuggestApi.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/core/api') diff --git a/src/core/api/searchSuggestApi.js b/src/core/api/searchSuggestApi.js index 3dabfbd6..c65405e3 100644 --- a/src/core/api/searchSuggestApi.js +++ b/src/core/api/searchSuggestApi.js @@ -1,8 +1,10 @@ import axios from 'axios' const searchSuggestApi = async ({ query }) => { + query = query.replace('&', '').trim() + if (!query) return {} const dataSearchSuggest = await axios( - `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/suggest?q=${query.trim()}` + `${process.env.NEXT_PUBLIC_SELF_HOST}/api/shop/suggest?q=${query}` ) return dataSearchSuggest } -- cgit v1.2.3