+
+
+
+
+ setStartDate(date)}
+ selectsStart
+ startDate={startDate}
+ />
+
+
+
+
+
+ setTitle(e.target.value)}
+ />
+ setContent(e.target.value)}
+ />
+
+
+
+
+
+ 취소
+ 저장
+
+
+ {isCancelModalOpen && (
+
+ 작성을 취소하시겠습니까?
+
+ }
+ w="70%"
+ h="15rem"
+ buttons={
+
+ 아니오
+ 예
+
+ }
+ />
+ )}
+
+ {isSaveModalOpen && (
+
+ 일기를 저장할까요?
+
+ }
+ w="70%"
+ h="15rem"
+ buttons={
+
+ 취소
+ 확인
+
+ }
+ />
+ )}
+
+ ;
+};
+
+const DateDiv = styled.div`
+ display: flex;
+ align-items: center;
+ background-color: none;
+ width: 80%;
+ border: none;
+ font-size: 15px;
+ border-bottom: solid #bfbfbf 1px;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 10%;
+`;
+const CalenderImage = styled.img`
+ padding: 1.2%;
+`;
+
+const StyledDatePicker = styled.div`
+ .react-datepicker-wrapper{
+ width: 70%;
+ }
+ .react-datepicker__input-container{
+ width: 100%;
+ }
+ .react-datepicker__input-container input {
+ background-color: none;
+ width: 100%;
+ border: none;
+ font-size: 15px;
+ &::placeholder {
+ color: #bfbfbf;
+ }
+ }
+`;
+
+
+const TitleBox = styled.input`
+ display: flex;
+ background-color: none;
+ width: 92%;
+ border: none;
+ font-size: 15px;
+ border-bottom: solid ${COLOR.MAIN_SKY} 1px;
+ margin: auto;
+ margin-top: 2rem;
+ padding-bottom: 1rem;
+ &::placeholder {
+ color: #bfbfbf;
+ }
+`;
+
+const ContentBox = styled.textarea`
+ display: flex;
+ background-color: none;
+ width: 92%;
+ height: 37rem;
+ border: none;
+ font-size: 15px;
+ margin: auto;
+ margin-top: 1rem;
+ &::placeholder {
+ color: #bfbfbf;
+ }
+`;
+
+const DiaryDiv = styled.div`
+ display: flex;
+ flex-direction: column;
+ background-color: none;
+ font-size: 15px;
+ color: #BFBFBF;
+ border: 1px solid ${COLOR.MAIN_SKY};
+ border-radius: 1.8rem;
+ margin-top: 2.5rem;
+ margin-left: 8%;
+ margin-right: 8%;
+`;
+
+const BtnDiv = styled.div`
+ display: flex;
+ flex-direction: row;
+ justify-content: center;
+ align-items: center;
+ margin-top: 4%;
+ margin-bottom: 5rem;
+`;
+const CancelBtn = styled.button`
+ height: 4rem;
+ width: 14.5rem;
+ font-size: 1.8rem;
+ font-weight: 600;
+ background-color: white;
+ border: none;
+ border-radius: 3rem;
+ box-shadow: 2px 3px 5px 0px rgba(0, 0, 0, 0.3);
+ margin-right: 3%;
+`;
+const SaveBtn = styled.button`
+ height: 4rem;
+ width: 14.5rem;
+ font-size: 1.8rem;
+ font-weight: 600;
+ color: white;
+ background-color: #2EABA1;
+ border: none;
+ border-radius: 3rem;
+ box-shadow: 2px 3px 5px 0px rgba(0, 0, 0, 0.4);
+ margin-left: 3%;
+ background-color: ${(props) => props.disabled ? "rgba(46, 171, 161, 0.3)" : "${COLOR.MAIN_EMER}"}
+`;
+const OkayBtn = styled.button`
+ height: 2.5rem;
+ width: 10rem;
+ font-size: 1.7rem;
+ font-weight: 600;
+ text-align: center;
+ vertical-align: center;
+ color: white;
+ border: none;
+ border-radius: 3rem;
+ &.no {
+ color: black;
+ background-color: #D9D9D9;
+ margin-right: 1rem;
+ }
+ &.yes {
+ background-color: ${COLOR.MAIN_GREEN};
+ }
+`;
+const OkayDiv = styled.div`
+ margin-top: 3rem;
+`;
+
+const ContentDiv = styled.div`
+ text-align: center;
+ font-size: 1.8rem;
+ margin-top: 4rem;
+`;
+
+
+export default EditDiaryWritePage;
+
+
diff --git a/src/pages/EditTripPage.js b/src/pages/EditTripPage.js
new file mode 100644
index 0000000..711e991
--- /dev/null
+++ b/src/pages/EditTripPage.js
@@ -0,0 +1,323 @@
+import styled, { css } from "styled-components";
+import React, { useState } from "react";
+import SelectDateRange from "../components/common/SelectDateRange";
+import ImageUploader from "../components/common/ImageUploader";
+import SearchPlaceModal from "../components/common/SearchPlaceModal";
+import { PiMapPinFill } from "react-icons/pi";
+import PropTypes from "prop-types";
+import { useNavigate } from "react-router-dom";
+import { useLocation } from "react-router";
+import { COLOR } from "../styles/color";
+import moment from "moment";
+import axios from "axios";
+import BottomNav from "../layout/BottomNav";
+import Modal from "../components/common/Modal";
+import SuccessContent from "../components/common/SuccessAddTripContent";
+
+const EditTripPage = () => {
+ const { state } = useLocation();
+ const navigate = useNavigate();
+ //모달창(여행지 검색) 관리 변수
+ const [isModal, setIsModal] = useState(false);
+
+ const [success, setIsSuccess] = useState(false);
+ // 사용자 입력 정보(여행이름)
+ const [tripName, setTripName] = useState(state.state.title);
+ //사용자 입력 정보(여행지역)
+ const [tripPlace, setTripPlace] = useState(state.state.location.region);
+ const [longitude, setLongitude] = useState(state.state.location.longitude);
+ const [latitude, setLatitude] = useState(state.state.location.latitude);
+ //사용자 입력 정보(여행날짜)
+ const [dateRange, setDateRange] = useState([
+ state.state.startdate,
+ state.state.enddate,
+ ]);
+ const [startDate, setStartDate] = useState(state.state.startdate);
+ const [endDate, setEndDate] = useState(state.state.enddate);
+ //사용자 업로드 이미지 url
+ const [imgUrl, setImgUrl] = useState(state.url);
+
+ const openSuccessModal = () => {
+ setIsSuccess(true);
+ };
+ const closeSuccessModal = () => {
+ setIsSuccess(false);
+ navigate("/home");
+ };
+
+ // 여행 이름값 변경
+ const handleNameChange = (e) => {
+ setTripName(e.target.value);
+ };
+ // 여행 장소 값 변경
+ const handlePlaceChange = (e) => {
+ setTripPlace(e.target.value);
+ };
+ // 여행 날짜 값 변경
+ const handleDateChange = (e) => {
+ setDateRange(e);
+ const [start, end] = e;
+ setStartDate(start);
+ setEndDate(end);
+ };
+
+ // 여행떠나기 버튼 클릭
+ const handleSubmit = () => {
+ const startdate = moment(startDate)
+ .startOf("day")
+ .format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
+ const enddate = moment(endDate)
+ .endOf("day")
+ .format("YYYY-MM-DDTHH:mm:ss.SSS[Z]");
+ const formData = new FormData();
+ formData.append("title", tripName);
+ formData.append("startdate", startdate);
+ formData.append("enddate", enddate);
+ formData.append("location[region]", tripPlace);
+ formData.append("location[latitude]", latitude);
+ formData.append("location[longitude]", longitude);
+ formData.append("image", imgUrl.fileObject);
+
+ axios
+ .put(`${process.env.REACT_APP_SERVER_URL}/travel/${state.state._id}`, formData, {
+ withCredentials: true,
+ headers: { "Content-Type": "multipart/form-data" },
+ })
+ .then((res) => {
+ openSuccessModal();
+ })
+ .catch((error) => {
+ console.log(error);
+ });
+ };
+
+ const handleCancel = () => {
+ navigate("/home");
+ };
+
+ const openModal = () => {
+ setIsModal(true);
+ };
+
+ return (
+