Skip to content

Commit

Permalink
Feat: succeed edit diary get date, ttitle, content state(except url i…
Browse files Browse the repository at this point in the history
…mage) #106
  • Loading branch information
HeeNamgoong committed May 21, 2024
1 parent e6add3d commit 7c05f7a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/pages/DiaryPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const DiaryPage = () => {
console.log(error);
});

navigate("/editdiary"); // {diaryid} 추가
navigate("/editdiary", { state: { diaryInfo } });
};


Expand Down
2 changes: 1 addition & 1 deletion src/pages/DiaryWritePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const DiaryWritePage = () => {
formData.append("title", title);
formData.append("content", content);
formData.append("date", startDate.toISOString().split("T")[0]);
formData.append("travel", "664c257dac93cdbc69a66bf5"); // travelid 대체
formData.append("travel", "664c3dc4300f7b0c6126c483"); // travelid 대체

files.forEach((file) => {
formData.append("images", file.fileObject);
Expand Down
13 changes: 8 additions & 5 deletions src/pages/EditDiaryWritePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@ import { useNavigate } from "react-router-dom";
import { useLocation } from "react-router";

const EditDiaryWritePage = () => {
const { state } = useLocation();
const { diaryInfo } = state || {};

const [startDate, setStartDate] = useState(diaryInfo?.date ? new Date(diaryInfo.date) : null);
const [title, setTitle] = useState(diaryInfo?.title || "");
const [content, setContent] = useState(diaryInfo?.content || "");
const [files, setFiles] = useState(diaryInfo?.url || []);

const [startDate, setStartDate] = useState();
const [title, setTitle] = useState("");
const [content, setContent] = useState("");
const [isCancelModalOpen, setIsCancelModalOpen] = useState(false); // Cancel 버튼을 위한 모달 상태
const [isSaveModalOpen, setIsSaveModalOpen] = useState(false); // Save 버튼을 위한 모달 상태
const [imagePreview, setImagePreview] = useState(null);
const [files, setFiles] = useState([]);
const { state } = useLocation();
// const [files, setFiles] = useState([]);
// const [travelid, setTravelId] = useState(state);
const [diaryId, setDiaryId] = useState({ diaryid: "" });

Expand Down

0 comments on commit 7c05f7a

Please sign in to comment.