diff --git a/src/app/seminar/[id]/page.tsx b/src/app/seminar/[id]/page.tsx index 2dfea36..e726328 100644 --- a/src/app/seminar/[id]/page.tsx +++ b/src/app/seminar/[id]/page.tsx @@ -1,26 +1,47 @@ 'use client'; -import React from 'react'; +import React, {useEffect} from 'react'; import { usePathname } from 'next/navigation'; import SeminarDetailHeader from '@/components/seminar/seminarDetail/header/SeminarDetailHeader'; import SeminarDetailBanner from '@/components/seminar/seminarDetail/banner/SeminarDetailBanner'; import { SEMINAR_DATA } from '@/constants/seminar/seminarData'; +import { OPEN_SEMINAR_DATA } from '@/constants/seminar/openSeminarData'; import SeminarDetailPdf from '@/components/seminar/seminarDetail/pdf/SeminarDetailPdf'; import NotFoundPage from '@/app/not-found'; import SeminarDetailReview from '@/components/seminar/seminarDetail/review/SeminarDetailReview'; +import { SeminarThumnail } from '@/interfaces/seminar/seminarThumbnail'; import { changePathtoNumber } from '@/hooks/seminar/changePathtoNumber'; const SeminarDetailPage = () => { const pathname = usePathname(); - // 숫자 추출 - var id = changePathtoNumber(pathname); - - // 객체 찾기 - const seminar = SEMINAR_DATA.find(seminar => Number(seminar.id) === id); + let id = changePathtoNumber(pathname); + console.log(id); + + let data: SeminarThumnail | undefined; + + // 일반객체 + data = SEMINAR_DATA.find(seminar => `${seminar.id}` === `${id}`); + + // 오픈 세미나 데이터 + if (!data) { + let found = OPEN_SEMINAR_DATA.find(oseminar => + oseminar.seminars.some(seminar => `0${oseminar.id}${seminar.id}` === `${id}`) + ); - if (!id || !seminar) { - // 세미나를 찾지 못한 경우 - return ; + if (found) { + const matchingSeminar = found.seminars.find(seminar => `0${found.id}${seminar.id}` === `${id}`); + console.log('match', matchingSeminar); + + if (matchingSeminar) { + data = matchingSeminar; + } else { + // 일치하는 세미나를 찾지 못한 경우 + return ; + } + } else { + // 일치하는 OpenSeminar를 찾지 못한 경우 + return ; + } } @@ -28,16 +49,16 @@ const SeminarDetailPage = () => {
{/* header */} - + {/* banner */} - + {/* pdf file */} - + {/* review */} - +
diff --git a/src/components/seminar/openSeminarDetail/header/OpenSeminarDetailHeader.tsx b/src/components/seminar/openSeminarDetail/header/OpenSeminarDetailHeader.tsx index 056a317..1c8b47d 100644 --- a/src/components/seminar/openSeminarDetail/header/OpenSeminarDetailHeader.tsx +++ b/src/components/seminar/openSeminarDetail/header/OpenSeminarDetailHeader.tsx @@ -1,6 +1,6 @@ 'use client'; -import { OpenDetailSeminar, OpenSeminar } from '@/interfaces/seminar/openSeminar'; +import { OpenSeminar } from '@/interfaces/seminar/openSeminar'; import React, { useState } from 'react'; /** diff --git a/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarDetailSeminars.tsx b/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarDetailSeminars.tsx index 32b490f..10b4483 100644 --- a/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarDetailSeminars.tsx +++ b/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarDetailSeminars.tsx @@ -1,7 +1,6 @@ import React from 'react'; import OpenSeminarsDetailBox from './OpenSeminarsDetailBox'; import { OpenSeminar } from '@/interfaces/seminar/openSeminar'; -import { OPEN_SEMINAR_DATA } from '@/constants/seminar/openSeminarData'; import Link from 'next/link'; /** @@ -25,10 +24,15 @@ const OpenSeminarDetailSeminars = ({ data }: { data: OpenSeminar }) => {

{data.seminars.map((seminar, index) => ( + + ))}
diff --git a/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarsDetailBox.tsx b/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarsDetailBox.tsx index e73c985..fcdbc14 100644 --- a/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarsDetailBox.tsx +++ b/src/components/seminar/openSeminarDetail/kindOfSeminar/OpenSeminarsDetailBox.tsx @@ -1,4 +1,5 @@ -import { OpenDetailSeminar, OpenSeminar } from '@/interfaces/seminar/openSeminar'; +import { OpenSeminar } from '@/interfaces/seminar/openSeminar'; +import { SeminarThumnail } from '@/interfaces/seminar/seminarThumbnail'; import Image from 'next/image'; import React from 'react'; @@ -13,7 +14,7 @@ import React from 'react'; * Renders the header component for the recruitment section. * @returns The rendered header component. */ -const OpenSeminarsDetailBox = ({ data }: { data: OpenDetailSeminar }) => { +const OpenSeminarsDetailBox = ({ data }: { data: SeminarThumnail }) => { return (
@@ -29,9 +30,9 @@ const OpenSeminarsDetailBox = ({ data }: { data: OpenDetailSeminar }) => {
- {data.presenter}

{data.presenter_role}

+ {data.presenter_name}

{data.presenter_role}

-

{data.seminar_title}

+

{data.title}

); diff --git a/src/components/seminar/seminarDetail/banner/SeminarDetailBanner.tsx b/src/components/seminar/seminarDetail/banner/SeminarDetailBanner.tsx index c09a92a..146239d 100644 --- a/src/components/seminar/seminarDetail/banner/SeminarDetailBanner.tsx +++ b/src/components/seminar/seminarDetail/banner/SeminarDetailBanner.tsx @@ -21,8 +21,8 @@ const SeminarDetailBanner = ({ data }: { data: SeminarThumnail }) => { {/* 왼쪽 컨텐츠 */}
{`${data.presenter}'s_seminarimage`} { Speaker

- {data.presenter}

{data.role}

+ {data.presenter_name}

{data.presenter_role}

diff --git a/src/components/seminar/thumbnail/SeminarThumbnail.tsx b/src/components/seminar/thumbnail/SeminarThumbnail.tsx index d2f0b79..ab9a4d5 100644 --- a/src/components/seminar/thumbnail/SeminarThumbnail.tsx +++ b/src/components/seminar/thumbnail/SeminarThumbnail.tsx @@ -16,8 +16,8 @@ const SeminarThumbnail = ({ data }: { data: SeminarThumnail }) => { return (
{`${data.presenter}'s_seminarimage`} { +export const changePathtoNumber = (pathname: string) => { const match = pathname.match(/\/seminar\/(\d+)/); - const seminar_id = match ? parseInt(match[1], 10) : null; + const seminar_id = match ? match[1] : null; return seminar_id; } diff --git a/src/interfaces/seminar/openSeminar.ts b/src/interfaces/seminar/openSeminar.ts index f401f43..634f284 100644 --- a/src/interfaces/seminar/openSeminar.ts +++ b/src/interfaces/seminar/openSeminar.ts @@ -1,3 +1,5 @@ +import { SeminarThumnail } from "./seminarThumbnail"; + export interface OpenSeminar { id: number; flag: number; @@ -9,14 +11,5 @@ export interface OpenSeminar { information: string; image_url: string; status: boolean; - seminars: OpenDetailSeminar[]; -} - -export interface OpenDetailSeminar { - id: number; - presenter: string; - seminar_title: string; - presenter_role: string; - presenter_image_url: string; -} - \ No newline at end of file + seminars: SeminarThumnail[]; +} \ No newline at end of file diff --git a/src/interfaces/seminar/seminarThumbnail.ts b/src/interfaces/seminar/seminarThumbnail.ts index 21fc2e5..28db1dd 100644 --- a/src/interfaces/seminar/seminarThumbnail.ts +++ b/src/interfaces/seminar/seminarThumbnail.ts @@ -7,8 +7,9 @@ export interface SeminarThumnail { location: string; title: string; description: string; - presenter: string; - role: string; - image_url: string; + presenter_name: string; + presenter_role: string; + seminar_image_url: string; + presenter_image_url: string; } \ No newline at end of file