|
1 | | -import { useNavigate, useLocation } from 'react-router-dom'; |
| 1 | +import { useLocation, Link } from 'react-router-dom'; |
2 | 2 | import formatWorkTime from '@/utils/formatWorkTime'; |
3 | 3 | import ClockRed from '@/assets/icons/clock-red.svg'; |
4 | 4 | import ClockGray from '@/assets/icons/clock-gray.svg'; |
@@ -37,7 +37,6 @@ export default function Post({ data }: { data: NoticeShopItem }) { |
37 | 37 | item: { id: shopId, name, address1, imageUrl, originalHourlyPay }, |
38 | 38 | }, |
39 | 39 | } = data; |
40 | | - const navigate = useNavigate(); |
41 | 40 | const location = useLocation(); |
42 | 41 | const { addRecentlyViewed } = useRecentlyViewed(); |
43 | 42 | const status = getStatus(startsAt, closed); |
@@ -84,20 +83,15 @@ export default function Post({ data }: { data: NoticeShopItem }) { |
84 | 83 | } |
85 | 84 | } |
86 | 85 |
|
87 | | - const handleClick = () => { |
88 | | - addRecentlyViewed(data); |
| 86 | + const isOwnerPage = location.pathname.startsWith('/owner'); |
| 87 | + const linkPath = isOwnerPage |
| 88 | + ? `/owner/post/${shopId}/${noticeId}` |
| 89 | + : `/${shopId}/${noticeId}`; |
89 | 90 |
|
90 | | - const isOwnerPage = location.pathname.startsWith('/owner'); |
91 | | - |
92 | | - const path = isOwnerPage |
93 | | - ? `/owner/post/${shopId}/${noticeId}` |
94 | | - : `/${shopId}/${noticeId}`; |
95 | | - |
96 | | - navigate(path); |
97 | | - }; |
98 | 91 | return ( |
99 | | - <button |
100 | | - onClick={handleClick} |
| 92 | + <Link |
| 93 | + to={linkPath} |
| 94 | + onClick={() => addRecentlyViewed(data)} |
101 | 95 | className="flex h-261 w-full cursor-pointer flex-col gap-12 rounded-xl border border-gray-20 bg-white p-12 md:h-359 md:gap-20 md:p-16 lg:h-348" |
102 | 96 | > |
103 | 97 | <div className="relative"> |
@@ -171,6 +165,6 @@ export default function Post({ data }: { data: NoticeShopItem }) { |
171 | 165 | )} |
172 | 166 | </div> |
173 | 167 | </div> |
174 | | - </button> |
| 168 | + </Link> |
175 | 169 | ); |
176 | 170 | } |
0 commit comments