|
| 1 | +import { useNavigate, useLocation } from 'react-router-dom'; |
1 | 2 | import formatWorkTime from '@/utils/formatWorkTime'; |
2 | 3 | import ClockRed from '@/assets/icons/clock-red.svg'; |
3 | 4 | import ClockGray from '@/assets/icons/clock-gray.svg'; |
@@ -26,15 +27,17 @@ function getStatus( |
26 | 27 |
|
27 | 28 | export default function Post({ data }: { data: NoticeShopItem }) { |
28 | 29 | const { |
| 30 | + id: noticeId, |
29 | 31 | hourlyPay, |
30 | 32 | workhour, |
31 | 33 | startsAt, |
32 | 34 | closed, |
33 | 35 | shop: { |
34 | | - item: { name, address1, imageUrl, originalHourlyPay }, |
| 36 | + item: { id: shopId, name, address1, imageUrl, originalHourlyPay }, |
35 | 37 | }, |
36 | 38 | } = data; |
37 | | - |
| 39 | + const navigate = useNavigate(); |
| 40 | + const location = useLocation(); |
38 | 41 | const status = getStatus(startsAt, closed); |
39 | 42 | const isInactive = status !== 'ACTIVE'; |
40 | 43 | const overlayText = isInactive |
@@ -79,8 +82,20 @@ export default function Post({ data }: { data: NoticeShopItem }) { |
79 | 82 | } |
80 | 83 | } |
81 | 84 |
|
| 85 | + const handleClick = () => { |
| 86 | + const isOwnerPage = location.pathname.startsWith('/owner'); |
| 87 | + |
| 88 | + const path = isOwnerPage |
| 89 | + ? `/owner/post/${shopId}/${noticeId}` |
| 90 | + : `/${shopId}/${noticeId}`; |
| 91 | + |
| 92 | + navigate(path); |
| 93 | + }; |
82 | 94 | return ( |
83 | | - <div 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"> |
| 95 | + <button |
| 96 | + onClick={handleClick} |
| 97 | + 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" |
| 98 | + > |
84 | 99 | <div className="relative"> |
85 | 100 | <div |
86 | 101 | className="relative h-84 w-full rounded-xl bg-cover bg-center md:h-171 lg:h-160" |
@@ -152,6 +167,6 @@ export default function Post({ data }: { data: NoticeShopItem }) { |
152 | 167 | )} |
153 | 168 | </div> |
154 | 169 | </div> |
155 | | - </div> |
| 170 | + </button> |
156 | 171 | ); |
157 | 172 | } |
0 commit comments