Skip to content

Commit ca465e4

Browse files
authored
Merge pull request #146 from codeit-6team/fix/145-post-link
🐛 fix: Post 컴포넌트 내 div 태그를 link태그로 수정
2 parents 540e1c5 + 1ffb625 commit ca465e4

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/components/common/Post.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useNavigate, useLocation } from 'react-router-dom';
1+
import { useLocation, Link } from 'react-router-dom';
22
import formatWorkTime from '@/utils/formatWorkTime';
33
import ClockRed from '@/assets/icons/clock-red.svg';
44
import ClockGray from '@/assets/icons/clock-gray.svg';
@@ -37,7 +37,6 @@ export default function Post({ data }: { data: NoticeShopItem }) {
3737
item: { id: shopId, name, address1, imageUrl, originalHourlyPay },
3838
},
3939
} = data;
40-
const navigate = useNavigate();
4140
const location = useLocation();
4241
const { addRecentlyViewed } = useRecentlyViewed();
4342
const status = getStatus(startsAt, closed);
@@ -84,20 +83,15 @@ export default function Post({ data }: { data: NoticeShopItem }) {
8483
}
8584
}
8685

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}`;
8990

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-
};
9891
return (
99-
<button
100-
onClick={handleClick}
92+
<Link
93+
to={linkPath}
94+
onClick={() => addRecentlyViewed(data)}
10195
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"
10296
>
10397
<div className="relative">
@@ -171,6 +165,6 @@ export default function Post({ data }: { data: NoticeShopItem }) {
171165
)}
172166
</div>
173167
</div>
174-
</button>
168+
</Link>
175169
);
176170
}

0 commit comments

Comments
 (0)