-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Feat-세미나 디테일, 오픈 세미나 이동-id에 따른 데이터 값 분리 #41
- Loading branch information
Showing
3 changed files
with
64 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { usePathname } from 'next/navigation'; | ||
import OpenSeminarDetailHeader from '@/components/seminar/openSeminarDetail/header/OpenSeminarDetailHeader'; | ||
import OpenSeminarDetailBanner from '@/components/seminar/openSeminarDetail/banner/OpenSeminarDetailBanner'; | ||
import OpenSeminarDetailSeminars from '@/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarDetailSeminars'; | ||
import OpenSeminarDetailInformation from '@/components/seminar/openSeminarDetail/information/OpenSeminarDetailInformation'; | ||
import { OPEN_SEMINAR_DATA } from '@/constants/seminar/openSeminarData'; | ||
import NotFoundPage from '@/app/not-found'; | ||
import { changeOpenPathtoNumber } from '@/hooks/seminar/changePathtoNumber'; | ||
|
||
const OpenSeminarDetailPage = () => { | ||
const pathname = usePathname(); | ||
// 숫자 추출 | ||
var id = changeOpenPathtoNumber(pathname); | ||
|
||
// 객체 찾기 | ||
const seminar = OPEN_SEMINAR_DATA.find(seminar => Number(seminar.id) === id); | ||
|
||
if (!seminar) { | ||
// 세미나를 찾지 못한 경우 | ||
return <NotFoundPage />; | ||
} | ||
|
||
return <section className="flex justify-center"> | ||
<div className="max-w-[1200px] desktop:px-10 tablet:px-10 px-4"> | ||
<div className="w-full"> | ||
{/* header */} | ||
<OpenSeminarDetailHeader key={`${seminar.id}_header`} data={seminar}/> | ||
{/* banner */} | ||
<OpenSeminarDetailBanner key={`${seminar.id}_banner`} data={seminar}/> | ||
{/* seminars */} | ||
<OpenSeminarDetailSeminars key={`${seminar.id}_seminars`} data={seminar}/> | ||
{/* information */} | ||
<OpenSeminarDetailInformation key={`${seminar.id}_information`} data={seminar}/> | ||
</div> | ||
<div className="h-[120px]"></div> | ||
</div> | ||
</section>; | ||
}; | ||
|
||
export default OpenSeminarDetailPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export const changePathtoNumber = (pathname:string) => { | ||
const match = pathname.match(/\/seminar\/(\d+)/); | ||
const seminar_id = match ? parseInt(match[1], 10) : null; | ||
|
||
return seminar_id; | ||
} | ||
|
||
export const changeOpenPathtoNumber = (pathname:string) => { | ||
const match = pathname.match(/\/seminar\/open\/(\d+)/); | ||
const seminar_id = match ? parseInt(match[1], 10) : null; | ||
|
||
return seminar_id; | ||
} |