diff --git a/src/App.tsx b/src/App.tsx index da67e88..27a3aa3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -20,7 +20,7 @@ export default function App() { {/* 공통 페이지 */} } /> - } /> + } /> } /> } /> @@ -32,7 +32,7 @@ export default function App() { } /> - } /> + } /> diff --git a/src/components/common/Post.tsx b/src/components/common/Post.tsx index b9e12aa..6f0e28d 100644 --- a/src/components/common/Post.tsx +++ b/src/components/common/Post.tsx @@ -1,3 +1,4 @@ +import { useNavigate, useLocation } from 'react-router-dom'; import formatWorkTime from '@/utils/formatWorkTime'; import ClockRed from '@/assets/icons/clock-red.svg'; import ClockGray from '@/assets/icons/clock-gray.svg'; @@ -26,15 +27,17 @@ function getStatus( export default function Post({ data }: { data: NoticeShopItem }) { const { + id: noticeId, hourlyPay, workhour, startsAt, closed, shop: { - item: { name, address1, imageUrl, originalHourlyPay }, + item: { id: shopId, name, address1, imageUrl, originalHourlyPay }, }, } = data; - + const navigate = useNavigate(); + const location = useLocation(); const status = getStatus(startsAt, closed); const isInactive = status !== 'ACTIVE'; const overlayText = isInactive @@ -79,8 +82,20 @@ export default function Post({ data }: { data: NoticeShopItem }) { } } + const handleClick = () => { + const isOwnerPage = location.pathname.startsWith('/owner'); + + const path = isOwnerPage + ? `/owner/post/${shopId}/${noticeId}` + : `/${shopId}/${noticeId}`; + + navigate(path); + }; return ( -
+ ); } diff --git a/src/pages/store/StoreForm.tsx b/src/pages/store/StoreForm.tsx index 0eb640d..0f84f01 100644 --- a/src/pages/store/StoreForm.tsx +++ b/src/pages/store/StoreForm.tsx @@ -104,7 +104,7 @@ export default function StoreForm() { const handleModalConfirm = useCallback(() => { if (modal.message === '등록이 완료되었습니다.') { setModal({ isOpen: false, message: '' }); - navigate(`/owner/post/${noticeId.current}`); + navigate(`/owner/post/${shopId.current}/${noticeId.current}`); } else if (modal.message.includes('로그인')) { setModal({ isOpen: false, message: '' }); navigate('/login');