diff --git a/index.html b/index.html index e0d1c84..509fcdf 100644 --- a/index.html +++ b/index.html @@ -1,13 +1,23 @@ - - - - - Vite + React + TS - - -
- - - + + + + + + + + + Vite + React + TS + + + +
+ + + + \ No newline at end of file diff --git a/src/hooks/useGetSelection.ts b/src/hooks/useGetSelection.ts index f225f8a..4630437 100644 --- a/src/hooks/useGetSelection.ts +++ b/src/hooks/useGetSelection.ts @@ -1,12 +1,14 @@ +import { useSearchParams } from 'react-router-dom' import { useCallback } from 'react' import store, { IStore } from 'store/index' const useGetSelection = () => { + const [param] = useSearchParams() const selectorFn = useCallback( (state: IStore) => Object.keys(state.selection).reduce((acc, cur) => { - if (state.selection[cur] || cur === 'needCompanion') { - return { ...acc, [cur]: state.selection[cur] } + if (param.get(cur) || state.selection[cur] || cur === 'needCompanion') { + return { ...acc, [cur]: param.get(cur) || state.selection[cur] } } return { ...acc } }, {}), diff --git a/src/screen/Search.tsx b/src/screen/Search.tsx index 5500671..79d5760 100644 --- a/src/screen/Search.tsx +++ b/src/screen/Search.tsx @@ -1,5 +1,5 @@ import styled from 'styled-components' -import { ReactComponent as Kakao } from 'assets/kakao.svg' +import { ReactComponent as KakaoIcon } from 'assets/kakao.svg' import store from 'store/index' import { gql, useQuery } from '@apollo/client' @@ -9,6 +9,7 @@ import { GetSearchListQuery, GetSearchListQueryVariables } from 'api/graphql' import { useMemo } from 'react' import DestinationCard from 'components/Search/DestinationCard' import { Loading } from 'routes/Router' +import { useParams, useSearchParams } from 'react-router-dom' const SearchQuery = gql` query GetSearchList( @@ -77,6 +78,7 @@ const Search = () => { setToggle: state.setToggle, position: state.position, })) + const selection = useGetSelection() const variables = useMemo(() => { if (!position?.coords.latitude || !position?.coords.longitude) { @@ -102,7 +104,7 @@ const Search = () => { const hasNextPage = places?.pageInfo.hasNextPage const edges = useMemo(() => places?.edges, [places?.edges]) - console.log(loading, 'loading') + return loading || !called ? ( ) : ( @@ -121,7 +123,21 @@ const Search = () => { 내 주변 가까운
{places?.totalCount}개의 추천 관광지 - + { + window.Kakao.Share.sendCustom({ + templateId: 91940, + templateArgs: { + name: '???', + thumb_1: edges[0].node.thumbnails[0], + thumb_2: edges[1].node.thumbnails[0], + thumb_3: edges[2].node.thumbnails[0], + }, + installTalk: true, + callback: () => console.log('???'), + }) + }} + />