) => {
+ setText(e.target.value);
};
return {
- text, handleChange,
+ text,
+ handleChange,
};
};
@@ -24,22 +24,15 @@ export default function Search(): JSX.Element {
const { text, handleChange } = useSearchForm();
const isSearching = useSearchingMode();
const { isMobile } = useMediaQuery();
- const navigate = useNavigate();
return (
{isMobile && }
{isMobile ? !isSearching && : }
-
- {isMobile ? !isSearching && : }
+
+ {!isMobile && isSearching ? : }
-
);
diff --git a/src/pages/Search/static/recommend.tsx b/src/pages/Search/static/recommend.tsx
index fb9deff8..5a2fd1fc 100644
--- a/src/pages/Search/static/recommend.tsx
+++ b/src/pages/Search/static/recommend.tsx
@@ -5,18 +5,18 @@ const RECOMMEND_TEXT = [
어떤 음식
이 땡기나요?
,
-
- 기름진 음식
- 이
-
- 그리운 날!
-
,
-
- 추억의 장소
- 를
-
- 검색을 통해 찾아보세요!
-
,
+ //
+ // 기름진 음식
+ // 이
+ //
+ // 그리운 날!
+ //
,
+ //
+ // 추억의 장소
+ // 를
+ //
+ // 검색을 통해 찾아보세요!
+ //
,
];
export default RECOMMEND_TEXT;
diff --git a/src/pages/SearchDetails/hooks/useFetchAutoComplete.ts b/src/pages/SearchDetails/hooks/useFetchAutoComplete.ts
new file mode 100644
index 00000000..18587ecb
--- /dev/null
+++ b/src/pages/SearchDetails/hooks/useFetchAutoComplete.ts
@@ -0,0 +1,29 @@
+import useGeolocation from 'utils/hooks/useGeolocation';
+import { useQuery } from 'react-query';
+import { fetchAutoComplete } from 'api/search';
+import { FetchAutoCompleteParams } from 'api/search/entity';
+
+const useFetchAutoComplete = (query: string) => {
+ const options = {
+ maximumAge: 1000,
+ };
+ const { location } = useGeolocation(options);
+
+ const params: FetchAutoCompleteParams = { query };
+ if (location) {
+ params.location = location;
+ }
+
+ const {
+ isLoading, isError, data, refetch,
+ } = useQuery(['shop', query], () => fetchAutoComplete(params), { enabled: !!query });
+
+ const isFetching = isLoading || !(location);
+ const shop = data?.data;
+
+ return {
+ isFetching, isError, query: shop, refetch,
+ };
+};
+
+export default useFetchAutoComplete;