Skip to content

Commit

Permalink
Feat: fix data map error and change get data form #100
Browse files Browse the repository at this point in the history
  • Loading branch information
hummingbbird committed May 23, 2024
1 parent c39200f commit a03a129
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/components/common/DiaryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import { PropTypes } from "prop-types";
export default function TripTable(props) {
return (
<StTripTable>
{props.data && props.data.map((it)=> {
return <DiaryListItem key={it._id} data={it}/>;
})}
{
props.data.map((it) => {
return <DiaryListItem key={it._id} data={it.diary}/>;
})}
</StTripTable>
);
}

TripTable.propTypes = {
data: PropTypes.node.isRequired,
data: PropTypes.array.isRequired,
};

const StTripTable = styled.div`
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/DiaryListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function DiaryListItem(props) {
<TitleP>{props.data.title}</TitleP>
<DateDiv>
<DateP>{props.data.startdate}</DateP>
<UserP>{props.data.userId}</UserP>
<UserP>{props.data.userName}</UserP>
</DateDiv>
</InfoDiv>
</ContentDiv>
Expand All @@ -55,7 +55,7 @@ const StDiaryListItem = styled.div`
border: 0.2rem solid rgba(228, 228, 228);
border-radius: 1rem;
width: 100%;
height: 100%;
height: 10rem;
margin-bottom: 0.8rem;
box-shadow: 1px 1px 3px rgba(228, 228, 228);
`;
Expand Down
5 changes: 2 additions & 3 deletions src/components/common/TripListItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default function TripListItem(props) {

const goToDiaryList = () => {
setTripName(props.data.title);
// console.log("props.data._id: ", props.data._id);
navigate("/triptable", {
state: { id: props.data._id},
});
Expand Down Expand Up @@ -99,9 +100,7 @@ export default function TripListItem(props) {

TripListItem.propTypes = {
data: PropTypes.node.isRequired,
_id: PropTypes.string.isRequired,
title: PropTypes.string.isRequired,
url: PropTypes.string.isRequired,
url: PropTypes.array.isRequired,
};

const CancelModal = styled(Modal)``;
Expand Down
9 changes: 5 additions & 4 deletions src/pages/DiaryListPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { tripNameState } from "../recoil/commonState";
export default function DiaryListPage() {
const tripName = useRecoilValue(tripNameState);
const navigate = useNavigate();
//여행 id location으로 받음
const location = useLocation();
const [loading, setLoading] = useState(false);
const [data, setData] = useState([]);
Expand All @@ -32,7 +33,8 @@ export default function DiaryListPage() {
{ withCredentials: true },
);
if (!completed) {
setData(result.data.diarys);
// console.log("diarys:", result.data.diarys_info);
setData(result.data.diarys_info);
}
setLoading(true);
}
Expand All @@ -43,12 +45,11 @@ export default function DiaryListPage() {
}, []);

const goToAdd = () => {
navigate("/invitefriend", {state: location.state.id});
navigate("/invitefriend", {state: {id: location.state.id }});
};
const goToCreate = () => {
navigate("/diary", {state: location.state.id});
navigate("/diary", {state: {id: location.state.id }});
};

return (
<StDiaryListPage>
<TitleDiv>
Expand Down
4 changes: 2 additions & 2 deletions src/pages/DiaryWritePage.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const DiaryWritePage = () => {
const [isSaveModalOpen, setIsSaveModalOpen] = useState(false); // Save 버튼을 위한 모달 상태
const [imagePreview, setImagePreview] = useState(null);
const [files, setFiles] = useState([]);
const { state } = useLocation();
const location = useLocation();
// const [travelid, setTravelId] = useState(state);
const [diaryId, setDiaryId] = useState({ diaryid: "" });

Expand All @@ -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", location.state.id); // travelid 대체

files.forEach((file) => {
formData.append("images", file.fileObject);
Expand Down

0 comments on commit a03a129

Please sign in to comment.