Skip to content

Commit

Permalink
Merge pull request #36 from 2023WISCOM/feature/#1-nav
Browse files Browse the repository at this point in the history
Refactor: 백 url 수정
  • Loading branch information
harim061 authored Nov 1, 2023
2 parents 9950075 + 876fbff commit 2128276
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 67 deletions.
21 changes: 1 addition & 20 deletions WISCOM/src/components/Project/Developer.jsx
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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 (
<D.DeveloperContainer>
{data && (
Expand Down
5 changes: 3 additions & 2 deletions WISCOM/src/components/Project/ImageSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -56,7 +57,7 @@ const ImageSlider = () => {
<I.BannerImage
key={index}
className={`${index === currentIdx ? 'active' : ''}`}
src={`https://dswuwis.store/${image}`}
src={`http://13.124.248.135/${image}`}
alt={`slide ${index}`}
/>
))}
Expand Down
20 changes: 1 addition & 19 deletions WISCOM/src/components/Project/IntroWork.jsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
22 changes: 2 additions & 20 deletions WISCOM/src/components/Project/WorkInfo.jsx
Original file line number Diff line number Diff line change
@@ -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 (
<W.WorkContainer>
{data && (
<>
<W.WorkLogo src={`https://dswuwis.store/${data.logo}`} alt="작품 로고" />
<W.WorkLogo src={`http://13.124.248.135/${data.logo}`} alt="작품 로고" />
<W.WorkInfoContent>
<W.Text fs="60px">{data.title}</W.Text>
<W.Text fs="50px">{data.team}</W.Text>
Expand Down
31 changes: 25 additions & 6 deletions WISCOM/src/page/Project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ProjectWrapper>
<WorkInfo />
<IntroWork />
<ImageSlider />
<Developer />
<Likes />
<Comment />
<WorkInfo data={data} />
<IntroWork data={data} />
<ImageSlider data={data} />
<Developer data={data} />
<Likes data={data} />
<Comment data={data} />
</ProjectWrapper>
);
}
Expand Down

0 comments on commit 2128276

Please sign in to comment.