From 288af1585683e225f46a049c80d9299e4937c78b Mon Sep 17 00:00:00 2001 From: tpfls <165572388+tpfls@users.noreply.github.com> Date: Wed, 14 Aug 2024 22:19:32 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=A9=94=EC=9D=B8=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 2 +- package.json | 1 + src/App.js | 55 ++++---------- src/pages/Main.jsx | 150 ++++++++++++++++++++++++++----------- src/pages/MyPage.jsx | 12 +-- src/styles/MyPagestyle.jsx | 42 +++++++---- 6 files changed, 155 insertions(+), 107 deletions(-) diff --git a/package-lock.json b/package-lock.json index 585621a..3fdabd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19303,4 +19303,4 @@ } } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index d6a4e1a..83c81e1 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "react-scripts": "^5.0.1", "react-time-picker": "^7.0.0", "styled-components": "^6.1.12", + "tailwind": "^4.0.0", "tailwindcss": "^3.4.9", "web-vitals": "^2.1.4", "xlsx": "^0.18.5" diff --git a/src/App.js b/src/App.js index 2ce4115..47acb02 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,5 @@ import React from 'react'; -import { - BrowserRouter as Router, - Route, - Routes, - useLocation, -} from 'react-router-dom'; +import { BrowserRouter as Router, Route, Routes, useLocation } from 'react-router-dom'; import Main from './pages/Main'; import Home from './pages/Home'; import Login from './pages/Login'; @@ -14,9 +9,7 @@ import MyLocationList from './pages/MyLocationList'; import Setting from './pages/Setting'; import MakePlanRoom1 from './pages/MakePlanRoom1'; import MakePlanRoom2 from './pages/MakePlanRoom2'; -import PlanRoomResult from './pages/PlanRoomResult'; import PlanRoom1 from './pages/PlanRoom1'; -import PlanRoom2 from './pages/PlanRoom2'; import NotFound from './pages/NotFound'; import Navbar from './components/Navbar'; import Sidebar from './components/Sidebar'; @@ -25,9 +18,12 @@ import FindPassword from './pages/FindPassword'; import FindPasswordSend from './pages/FindPasswordsend'; import EmailCheck from './pages/emailcheck'; import StartPlanRoom from './pages/StartPlanRoom'; -import Notice from './pages/Notice'; -import PrNavbar from './components/PrNavbar'; +import PrNavbar from './components/PrNavbar'; import MainNavbar from './components/MainNavbar'; +import Home2 from './pages/home2'; +import Notice from './pages/Notice'; +import PlanRoom2 from './pages/PlanRoom2'; + const AppContainer = styled.div` display: flex; @@ -40,35 +36,14 @@ const ContentContainer = styled.div` function App() { const location = useLocation(); - const MainNavBarPages = [ - '/', - '/login', - '/SignUp', - '/emailcheck', - '/findpassword', - ]; - const sideBarPages = [ - '/Home', - '/MakePlanRoom1', - '/MakePlanRoom2', - '/StartPlanRoom', - '/MyPage', - '/MyPage2', - '/MyPage3', - '/Notice', - '/Setting', - '/MyLocationList', - ]; + const MainNavBarPages=['/','/login','/SignUp','/emailcheck','/findpassword']; + const sideBarPages=['/Home','/MakePlanRoom1','/MakePlanRoom2','/StartPlanRoom', + '/MyPage','/MyPage2','/MyPage3','/Notice','/Setting','/MyLocationList' ]; return ( <> - {MainNavBarPages.includes(location.pathname) ? ( - - ) : location.pathname === '/PlanRoom1' ? ( - - ) : ( - - )} + {MainNavBarPages.includes(location.pathname) ? : + (location.pathname==='/PlanRoom1' ? : )} {sideBarPages.includes(location.pathname) && } @@ -81,17 +56,17 @@ function App() { } /> } /> } /> - } /> } /> + } /> } /> } /> } /> } /> } /> } /> - } /> - } /> } /> + } /> + } /> } /> @@ -108,4 +83,4 @@ function AppWrapper() { ); } -export default AppWrapper; +export default AppWrapper; \ No newline at end of file diff --git a/src/pages/Main.jsx b/src/pages/Main.jsx index b09a533..3d1ac10 100644 --- a/src/pages/Main.jsx +++ b/src/pages/Main.jsx @@ -1,6 +1,13 @@ import React from 'react'; -import { useNavigate } from 'react-router-dom'; +import { useNavigate } from 'react-router-dom'; // useHistory 대신 useNavigate 사용 + const Main = () => { + const navigate = useNavigate(); // useHistory 대신 useNavigate 사용 + + const handleButtonClick = () => { + navigate('/startplanroom'); // startplanroom으로 이동 + }; + const containerStyle = { display: 'flex', flexDirection: 'column', @@ -32,94 +39,147 @@ const Main = () => { }; const videoContainerStyle = { - marginBottom: '40px', - height: '300px', - backgroundColor: '#ccc', + marginBottom: '50px', + height: '450px', display: 'flex', alignItems: 'center', justifyContent: 'center', - fontSize: '1.5em', - color: 'black', }; - const cardContainerStyle = { - display: 'flex', - flexWrap: 'wrap', - justifyContent: 'center', - marginTop: '40px', + const videoStyle = { + width: '100%', + height: '100%', + borderRadius: '10px', + boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)', }; - const cardStyle = { + const footerStyle = { + marginTop: '40px', + padding: '20px', backgroundColor: '#343a40', color: 'white', + textAlign: 'center', + width: '100%', + }; + + // 카드 컨테이너 1 + const cardContainer1Style = { + backgroundColor: '#f8f9fa', + color: 'black', + borderRadius: '10px', + padding: '15px', + margin: '10px', + width: '350px', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + marginRight: '500px', + }; + + // 카드 컨테이너 2 + const cardContainer2Style = { + backgroundColor: '#f8f9fa', + color: 'black', borderRadius: '10px', padding: '20px', margin: '10px', width: '300px', - boxShadow: '0 4px 8px rgba(0, 0, 0, 0.2)', display: 'flex', flexDirection: 'column', alignItems: 'center', + marginLeft: '500px', + marginTop:'-180px', }; - const footerStyle = { - marginTop: '40px', + // 카드 컨테이너 3 + const cardContainer3Style = { + backgroundColor: '#f8f9fa', + color: 'black', + borderRadius: '10px', padding: '20px', - backgroundColor: '#343a40', - color: 'white', - textAlign: 'center', - width: '100%', + margin: '10px', + width: '300px', + display: 'flex', + flexDirection: 'column', + alignItems: 'center', + marginRight: '500px', + marginTop:'-150px', }; - const navigate = useNavigate(); + + + +// 이미지 스타일 추가 +const image1Style = { + width: '100%', // 원하는 크기로 조정 + height: '300PX', + position: 'relative', // 부모 요소의 position을 relative로 설정 + left: '500px', // 카드 컨테이너와 같은 위치로 설정 + top: '-250px', // 이미지 위치를 위로 올리기 위해 음수 값 설정 +}; + + +const image2Style={ + width:'100%', + height:'300px', + position:'relative', + right:'480px', + top:'-250px', +}; + +const image3Style={ + width:'100%', + height:'300px', + position:'relative', + left:'480px', + top:'-270px', +}; - const handleOutClick = () => { - navigate('/MakePlanRoom1'); - }; return (

국내 여행을 계획하고 있으신가요?

-

- 가볼까?와 동행자와 함께 여행을 빠르고 쉽게 계획할 수 있어요! -

- +

가볼까?와 동행자와 함께 여행을 빠르고 쉽게 계획할 수 있어요!

+ -
(서비스 소개 영상)
+
+ +
-
-
+
+

여행 동행자와 함께 여행 계획을!

-

- 가볼까에서는 모두 다함께 참여할 수 있어요! 더 이상 따로 찾고 따로 - 계획하지 않아도 돼요! -

+

가볼까에서는 모두 다함께 참여할 수 있어요! 더 이상 따로 찾고 따로 계획하지 않아도 돼요!

+ {/* 이미지 추가 */}
-
+ +

가볼까의 주요 장점 제목 222

가볼까의 장점 설명글 가볼까의 장점 설명글 가볼까의 장점 설명글

+
-
+ +

가볼까의 주요 장점 제목 444

가볼까의 장점 설명글 가볼까의 장점 설명글 가볼까의 장점 설명글

+
- UMC 6기 타이거지부 ‘가볼까’ -
- 메일: 010711yj@swu.ac.kr | 고객센터: 0000-0000 -
- 서울시 OO구 OO로OO길 OO OOOO (우편번호00000) -
© GABOLKKA ALL RIGHTS RESERVED. + UMC 6기 타이거지부 ‘가볼까’
+ 메일: 010711yj@swu.ac.kr | 고객센터: 0000-0000
+ 서울시 OO구 OO로OO길 OO OOOO (우편번호00000)
+ © GABOLKKA ALL RIGHTS RESERVED.
); }; -export default Main; +export default Main; \ No newline at end of file diff --git a/src/pages/MyPage.jsx b/src/pages/MyPage.jsx index 15db237..8b1710b 100644 --- a/src/pages/MyPage.jsx +++ b/src/pages/MyPage.jsx @@ -18,11 +18,11 @@ import { Input, Button, StyledH2, - WithdrawSection, // 추가된 컴포넌트 - NoticeBox, // 추가된 컴포넌트 - NoticeItem, // 추가된 컴포넌트 - Checkbox, // 추가된 컴포넌트 - WithdrawButton // 추가된 컴포넌트 + WithdrawSection, + NoticeBox, + NoticeItem, + Checkbox, + WithdrawButton } from '../styles/MyPagestyle'; const Mypage = () => { @@ -79,7 +79,7 @@ const Mypage = () => { {activeTab === 'memberInfo' && ( // 회원정보 버튼이 클릭되었을 때만 표시 -

회원 정보

+

회원 정보

✏️ diff --git a/src/styles/MyPagestyle.jsx b/src/styles/MyPagestyle.jsx index 7830667..72724cc 100644 --- a/src/styles/MyPagestyle.jsx +++ b/src/styles/MyPagestyle.jsx @@ -18,13 +18,13 @@ export const Title = styled.h1` export const StyledH2 = styled.h2` font-size: 2rem; /* 원하는 글자 크기 */ - margin: 20px 0; /* 위 아래 여백 조정 */ - text-align: left; /* 제목을 왼쪽 정렬 */ + margin: 30px 20px; /* 위 아래 여백 조정 */ + text-align: center; /* 제목을 왼쪽 정렬 */ /* 필요에 따라 추가적인 스타일을 적용 */ `; export const Tabs = styled.div` - margin-bottom: 25px; + margin-bottom: 30px; text-align: left; justify-content: flex-start; `; @@ -46,24 +46,24 @@ export const TabButton = styled.button` `; export const ProfileSection = styled.div` - text-align: left; + text-align: center; background-color: #EDEDED; - padding: 140px; + padding: 80px 40px 40px 40px; /* 위쪽 여백을 100px로 줄였습니다 */ border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* box-shadow 추가 */ `; export const ProfilePicture = styled.div` display: flex; - justify-content: left; + justify-content: center; align-items: center; margin-bottom: 60px; /* 간격 조정 */ `; export const PicturePlaceholder = styled.div` - width: 70px; /* 원의 크기 */ - height: 70px; - border-radius: 50%; + width: 200px; /* 원의 크기 */ + height: 200px; + border-radius:50%; background-color: gray; display: flex; justify-content: center; @@ -73,8 +73,8 @@ export const PicturePlaceholder = styled.div` export const EditIcon = styled.div` position: absolute; /* 부모 요소에 상대적으로 위치 */ - bottom: -5px; /* 아래로 살짝 이동 */ - right: -5px; /* 오른쪽으로 살짝 이동 */ + bottom: -1px; /* 아래로 살짝 이동 */ + right: -1px; /* 오른쪽으로 살짝 이동 */ background-color: white; color: black; border-radius: 50%; @@ -85,13 +85,15 @@ export const EditIcon = styled.div` export const InfoItem = styled.div` margin-bottom: 30px; display: flex; - justify-content: left; + justify-content: center; align-items: center; + flex-direction: column; /* 세로 정렬을 위해 추가 */ `; export const InfoContent = styled.div` display: flex; align-items: center; + justify-content: center; /* 정보 내용 가운데 정렬 */ span { margin-right: 10px; @@ -153,9 +155,9 @@ export const ValidateButton = styled.button` export const SecuritySection = styled.div` background-color: #EDEDED; - padding: 50px; + padding: 60px; border-radius: 8px; - text-align: left; + text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* box-shadow 추가 */ `; @@ -197,12 +199,22 @@ export const Button = styled.button` } `; +export const Box = styled.div` + width: 100%; + margin-top: 10px; + padding: 10px; + background-color: #F0F0F0; + border-radius: 4px; + text-align: left; /* 텍스트 왼쪽 정렬 + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); +`; + // 추가된 스타일 컴포넌트 export const WithdrawSection = styled.div` background-color: #EDEDED; padding: 50px; border-radius: 8px; - text-align: left; + text-align: center; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* box-shadow 추가 */ `; From aae10eeb4554319de4249679d13e358afc5c850e Mon Sep 17 00:00:00 2001 From: tpfls <165572388+tpfls@users.noreply.github.com> Date: Tue, 20 Aug 2024 00:59:28 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 1 + src/buttonimage/exdown.png | Bin 0 -> 4216 bytes src/pages/Home.jsx | 61 +++++++++++++++++++++++++++----- src/pages/MakePlanRoom1.jsx | 53 ++++++++++++++++++++++++++-- src/pages/MakePlanRoom2.jsx | 9 +++-- src/pages/PlanRoom1.jsx | 36 +++++++++++++------ src/pages/PlanRoom2.jsx | 29 +++++++++------- src/pages/PlanRoomResult.jsx | 63 +++++++++++++++++++++++----------- src/pages/SignUp.jsx | 17 +++++++-- src/pages/home2.jsx | 10 ++++-- src/redux/appWrapper.js | 13 +++++++ src/redux/dataSlice.js | 34 ++++++++++++++++++ src/redux/store.js | 10 ++++++ src/styles/PlanRoom2style.jsx | 4 +-- src/styles/homestyle.jsx | 2 +- 15 files changed, 275 insertions(+), 67 deletions(-) create mode 100644 .env create mode 100644 src/buttonimage/exdown.png create mode 100644 src/redux/appWrapper.js create mode 100644 src/redux/dataSlice.js create mode 100644 src/redux/store.js diff --git a/.env b/.env new file mode 100644 index 0000000..87a5b60 --- /dev/null +++ b/.env @@ -0,0 +1 @@ +REACT_APP_KAKAO_API_KEY = b1d6aed50bab9834340e45aa8d0a6b67 diff --git a/src/buttonimage/exdown.png b/src/buttonimage/exdown.png new file mode 100644 index 0000000000000000000000000000000000000000..8082ec81c6ac9dd4af33a0e0c3985b0ae7608546 GIT binary patch literal 4216 zcmdUy_g522u*c&?QAC<3%>V*=X;K73O@j1tB^V$S0Z||#AVx~)ponx5G!L*f34G5x&2z29*X)lwJv3hy+!ZIK0KW6(Ox}bOioVz_>*~aDVx*y;XiCF zIbTp8CBCc9QV&)py;$a|FWdAv0O0j);3)v$VjQbNxBv1v4FH&2#j;L0n)z5Rks5yi z0M~ep0e}~$|IeL|DUMU)0b}0Xe!URt@$Ul$S^fFZdK>bjaix}#c5<>rAdkk@>`sPe zIy|i@&`>?wuztx)3YC4_9ydz*KQx~8jFWh zz#HvS%uP-~#aq4L&90MrXJm1#hTnYG1{ycj#G^BQ{CmVbr(&+8yqVtu+~3tgAUBMT zhi!I8ZR2-kENXe`199c8E?4Am4-JsTVUrPu%uZ@gjt(u&Tb5=Ov|QSjwheXU{t}DuM^B%$5%!{Ps)b%J{W&dzw<-8x-=2HjBf6tlQtvAsh~Zq7BTE#9ia5MDXEqnRoEw2@hneZv#CyvM3V{353!OJmi=c zeP1N&9Pe3vjovue8ADa=s{c(a9*!|X%3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?(ZxdHi?+6qIvY|<>N zA16e;KOi!kC^xprPVg)5$|8AidCSPk!=}vC#n|lMN0MFjtYw#54zzKaGX<)3VB(f-UlBI0N0%?+i-qm3%B zEo$WL2)`MO`f+Hf-T1S$t)c%VYh5qYvCo>u`ev_ABU$j6^ZWgv&%DEC%dC(9Q$v^m JN$ { + const fetchTravelPlans = async () => { + try { + const response = await fetch('https://your-backend-server-address/travel-plans/myRooms', { + method: 'GET', + headers: { + 'Authorization': 'Bearer ' + } + }); + + if (response.ok) { + const data = await response.json(); + setTravelPlans(data); + } else { + console.error('Failed to fetch data'); + } + } catch (error) { + console.error('Error:', error); + } + }; + + fetchTravelPlans(); + }, []); + + // 계획 만들기 버튼 클릭 핸들러 const handleCreatePlan = () => { navigate('/MakePlanRoom1'); }; return ( -
+

내가 참여한 여행

- +
-
@@ -29,15 +63,24 @@ function Home() {
- {Array(9).fill(0).map((_, index) => ( -
+ {travelPlans.map((plan, index) => ( +
여행
- 강원도 -

여행 제목

-

2024. 07. 13 - 2024. 8. 27

+ + {plan.region} + +

{plan.title}

+

+ {new Date(plan.start_date).toLocaleDateString()} -{' '} + {new Date(plan.end_date).toLocaleDateString()} +

diff --git a/src/pages/MakePlanRoom1.jsx b/src/pages/MakePlanRoom1.jsx index c5f79ba..7256075 100644 --- a/src/pages/MakePlanRoom1.jsx +++ b/src/pages/MakePlanRoom1.jsx @@ -8,6 +8,7 @@ import 'react-calendar/dist/Calendar.css'; import 'react-time-picker/dist/TimePicker.css'; import { format } from 'date-fns'; import moment from 'moment'; +import axios from 'axios'; /*컨테이너 및 구역 나눔*/ const FullContainner = styled.div` @@ -181,16 +182,22 @@ const Time = styled.div``; function MakePlanRoom1() { const [image, setImage] = useState(ImgUpload); + const [title, setTitle] = useState(''); // 여행 제목 상태 관리 + const [explain, setExplain] = useState(''); // 여행 설명 상태 관리 const [dateRange, setDateRange] = useState([new Date(), new Date()]); const [startDate, endDate] = dateRange; const [startTime, setStartTime] = useState('00:00'); const [endTime, setEndTime] = useState('00:00'); const [showTime, setShowTime] = useState(false); + const [imageFile, setImageFile] = useState(null); const fileInputRef = useRef(null); + const region='지역'; // MakePlanRoom2 이전에 미리 초기값 설정 (formData 넘기려고..) + const status=1; const handleImageUpload = (event) => { const file = event.target.files[0]; if (file) { + setImageFile(file); setImage(URL.createObjectURL(file)); } }; @@ -205,9 +212,48 @@ function MakePlanRoom1() { const navigate = useNavigate(); - const handleLink = () => { - navigate('/MakePlanroom2'); + const handleLink = async (travelId) => { + const [startDate, endDate] = dateRange; + const token = localStorage.getItem('token'); + console.log('JWT Token:', JSON.stringify(token)); + // FormData 생성 + const formData = new FormData(); + formData.append('title', title); + formData.append('start_date', format(startDate, 'yyyy-MM-dd')); + formData.append('end_date', format(endDate, 'yyyy-MM-dd')); + formData.append('explain', explain); + formData.append('start_time', showTime ? startTime : '00:00'); + formData.append('end_time', showTime ? endTime : '00:00'); + formData.append('region', region); // 추가된 지역 + formData.append('status', status); + + if (image) { + formData.append('travel_image', imageFile); // 선택된 파일 추가 + + try { + const response = await axios.post('http://43.200.238.249:5000/travel-plans/makeRoom', formData, { + headers: { + 'Authorization': `Bearer ${token}`, + 'Content-Type': 'multipart/form-data', + }, + }); + + const travelId = response.data.travel_id; + console.log('응답 데이터(FormData):', response.data); + console.log('여행 계획방 ID:', travelId); + + navigate('/MakePlanroom2', { state: { travelId } }); + + } catch (error) { + console.error('에러 발생:', error.response ? error.response.data : error.message); + if (error.response) { + console.error('서버 응답 오류:', error.response.data); + } + } + } }; + + return (

여행 계획방 만들기 (1/2)

@@ -241,12 +287,13 @@ function MakePlanRoom1() {
여행 제목
- + {setTitle(e.target.value)}}/>
여행 설명