diff --git a/src/components/Buyer/BuyerCategoryResult/CategoryResultHeader.tsx b/src/components/Buyer/BuyerCategoryResult/CategoryResultHeader.tsx
index 17bbd427..95563c5e 100644
--- a/src/components/Buyer/BuyerCategoryResult/CategoryResultHeader.tsx
+++ b/src/components/Buyer/BuyerCategoryResult/CategoryResultHeader.tsx
@@ -3,18 +3,24 @@ import { Grey1, Grey6, White } from 'styles/color';
import { Heading } from 'styles/font';
import { ReactComponent as Back } from 'assets/icons/icon-back.svg';
import { useNavigate } from 'react-router-dom';
+import { useCallback, useMemo } from 'react';
interface ResultHeaderProps {
categoryType: string;
}
export const CategoryResultHeader = ({ categoryType }: ResultHeaderProps) => {
+ const url = new URL(window.location.href);
+ const params = useMemo(() => new URLSearchParams(url.search), [url.search]);
const navigate = useNavigate();
+ const handleClickBackIcon = useCallback(() => {
+ if (params.has('from', 'search')) {
+ navigate('/search');
+ } else {
+ navigate('/share');
+ }
+ }, [navigate, params]);
return (
- {
- navigate(-1);
- }}
- />
+
{categoryType}
);
diff --git a/src/components/Buyer/Common/CartegorySearch.tsx b/src/components/Buyer/Common/CartegorySearch.tsx
index 0a4753c5..812cbd5a 100644
--- a/src/components/Buyer/Common/CartegorySearch.tsx
+++ b/src/components/Buyer/Common/CartegorySearch.tsx
@@ -1,11 +1,11 @@
-import { useNavigate } from 'react-router-dom';
+import { useLocation, useNavigate } from 'react-router-dom';
import { useSetRecoilState } from 'recoil';
import styled from 'styled-components';
import { Grey6 } from 'styles/color';
import { Characters } from 'utils/Characters';
import { searchKeywordState } from 'utils/atom';
-
export const CartegorySearch = () => {
+ const { pathname } = useLocation();
const navigate = useNavigate();
const setSearchKeyword = useSetRecoilState(searchKeywordState);
return (
@@ -16,7 +16,11 @@ export const CartegorySearch = () => {
number={1}
onClick={() => {
setSearchKeyword('연애갈등');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
연애갈등
@@ -26,7 +30,11 @@ export const CartegorySearch = () => {
number={2}
onClick={() => {
setSearchKeyword('이별/재회');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
이별/재회
@@ -36,7 +44,11 @@ export const CartegorySearch = () => {
number={3}
onClick={() => {
setSearchKeyword('여자심리');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
여자심리
@@ -46,7 +58,11 @@ export const CartegorySearch = () => {
number={4}
onClick={() => {
setSearchKeyword('남자심리');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
남자심리
@@ -58,7 +74,11 @@ export const CartegorySearch = () => {
number={5}
onClick={() => {
setSearchKeyword('썸/연애시작');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
썸/연애시작
@@ -68,7 +88,11 @@ export const CartegorySearch = () => {
number={6}
onClick={() => {
setSearchKeyword('짝사랑');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
짝사랑
@@ -78,7 +102,11 @@ export const CartegorySearch = () => {
number={7}
onClick={() => {
setSearchKeyword('권태기');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
권태기
@@ -88,7 +116,11 @@ export const CartegorySearch = () => {
number={8}
onClick={() => {
setSearchKeyword('기타');
- navigate('/categorySearch');
+ if (pathname === '/search') {
+ navigate('/categorySearch?from=search');
+ } else {
+ navigate('/categorySearch');
+ }
}}
/>
기타
diff --git a/src/pages/Buyer/BuyerHome.tsx b/src/pages/Buyer/BuyerHome.tsx
index a7a4a3a7..6152b1a6 100644
--- a/src/pages/Buyer/BuyerHome.tsx
+++ b/src/pages/Buyer/BuyerHome.tsx
@@ -26,7 +26,7 @@ export const BuyerHome = () => {
navigate('/share');
}
} catch (e) {
- console.log(e);
+ alert(e);
}
};
fectchSearchResults();