diff --git a/WISCOM/src/components/Project/Developer.jsx b/WISCOM/src/components/Project/Developer.jsx index b99cc9a..b27995c 100644 --- a/WISCOM/src/components/Project/Developer.jsx +++ b/WISCOM/src/components/Project/Developer.jsx @@ -1,5 +1,3 @@ -import { useState, useEffect } from 'react'; -import { useParams } from 'react-router-dom'; // useParams 가져오기 import * as D from './ProjectStyle'; import DeveloperProfile from './DeveloperProfile.jsx'; @@ -9,24 +7,7 @@ import BackYellow from '../../img/Project/BackgroundYellow.svg'; const backgroundImages = [BackGreen, BackBlue, BackGreen, BackYellow]; -// 재사용 쉽도록 수정 -const Developer = () => { - const [data, setData] = useState(null); - const { post_id } = useParams(); - - useEffect(() => { - // 정적 URL을 사용하여 데이터를 가져옵니다. - fetch(`https://dswuwis.store/posts/${post_id}/`, { - method: 'GET', - }) - .then((response) => response.json()) - .then((data) => { - setData(data); - console.log('가져와짐'); // 데이터를 성공적으로 가져온 후에 로깅 - }) - .catch((error) => console.error('Error fetching data:', error)); - }, [post_id]); - +const Developer = ({ data }) => { return ( {data && ( diff --git a/WISCOM/src/components/Project/ImageSlider.jsx b/WISCOM/src/components/Project/ImageSlider.jsx index 19d7573..f515544 100644 --- a/WISCOM/src/components/Project/ImageSlider.jsx +++ b/WISCOM/src/components/Project/ImageSlider.jsx @@ -13,8 +13,9 @@ const ImageSlider = () => { const [showArrows, setShowArrows] = useState(false); useEffect(() => { + const nextPostId = Number(post_id) + 1; // 정적 URL을 사용하여 데이터를 가져옵니다. - fetch(`https://dswuwis.store/posts/${post_id}/`, { + fetch(`http://13.124.248.135/posts/${nextPostId}/`, { method: 'GET', }) .then((response) => response.json()) @@ -56,7 +57,7 @@ const ImageSlider = () => { ))} diff --git a/WISCOM/src/components/Project/IntroWork.jsx b/WISCOM/src/components/Project/IntroWork.jsx index fc7d98f..8714088 100644 --- a/WISCOM/src/components/Project/IntroWork.jsx +++ b/WISCOM/src/components/Project/IntroWork.jsx @@ -1,24 +1,6 @@ -import { useState, useEffect } from 'react'; import * as I from './ProjectStyle'; -import { useParams } from 'react-router-dom'; // useParams 가져오기 - -const IntroWork = () => { - const [data, setData] = useState(null); - const { post_id } = useParams(); - - useEffect(() => { - // 정적 URL을 사용하여 데이터를 가져옵니다. - fetch(`https://dswuwis.store/posts/${post_id}/`, { - method: 'GET', - }) - .then((response) => response.json()) - .then((data) => { - setData(data); - console.log('가져와짐'); // 데이터를 성공적으로 가져온 후에 로깅 - }) - .catch((error) => console.error('Error fetching data:', error)); - }, [post_id]); +const IntroWork = ({ data }) => { const handleClickServiceURL = () => { if (data && data.service_url) { window.location.href = data.service_url; diff --git a/WISCOM/src/components/Project/WorkInfo.jsx b/WISCOM/src/components/Project/WorkInfo.jsx index 257bcda..6b3a8f0 100644 --- a/WISCOM/src/components/Project/WorkInfo.jsx +++ b/WISCOM/src/components/Project/WorkInfo.jsx @@ -1,29 +1,11 @@ -import { useState, useEffect } from 'react'; -import { useParams } from 'react-router-dom'; // useParams 가져오기 import * as W from './ProjectStyle'; -const WorkInfo = () => { - const [data, setData] = useState(null); - const { post_id } = useParams(); - - useEffect(() => { - // 정적 URL을 사용하여 데이터를 가져옵니다. - fetch(`https://dswuwis.store/posts/${post_id}/`, { - method: 'GET', - }) - .then((response) => response.json()) - .then((data) => { - setData(data); - console.log('가져와짐'); // 데이터를 성공적으로 가져온 후에 로깅 - }) - .catch((error) => console.error('Error fetching data:', error)); - }, [post_id]); - +const WorkInfo = ({ data }) => { return ( {data && ( <> - + {data.title} {data.team} diff --git a/WISCOM/src/page/Project.jsx b/WISCOM/src/page/Project.jsx index 59db3c2..7014d2f 100644 --- a/WISCOM/src/page/Project.jsx +++ b/WISCOM/src/page/Project.jsx @@ -5,16 +5,35 @@ import ImageSlider from '../components/Project/ImageSlider'; import Developer from '../components/Project/Developer'; import Likes from '../components/Project/Likes'; import Comment from '../components/Project/Comment'; +import { useEffect, useState } from 'react'; +import { useParams } from 'react-router-dom'; export default function Project() { + const [data, setData] = useState(null); + const { post_id } = useParams(); + + useEffect(() => { + const nextPostId = Number(post_id) + 1; + // 정적 URL을 사용하여 데이터를 가져옵니다. + fetch(`http://13.124.248.135/posts/${nextPostId}/`, { + method: 'GET', + }) + .then((response) => response.json()) + .then((data) => { + setData(data); + console.log('가져와짐'); // 데이터를 성공적으로 가져온 후에 로깅 + }) + .catch((error) => console.error('Error fetching data:', error)); + }, [post_id]); + return ( - - - - - - + + + + + + ); }