Skip to content

Commit

Permalink
Merge pull request #123 from TripTory/feature/116
Browse files Browse the repository at this point in the history
Chore: add diaryid recoil
  • Loading branch information
seo0o519 authored May 27, 2024
2 parents 39c347d + 3949728 commit d3d6da5
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 8 deletions.
12 changes: 10 additions & 2 deletions src/components/common/DiaryPreviewContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ import { COLOR } from "../../styles/color";
import leftBtn from "../../assets/icons/diary_left_btn.svg";
import rightBtn from "../../assets/icons/diary_right_btn.svg";
import moment from "moment";
import { useRecoilState } from "recoil";
import { tripIdState, diaryIdState } from "../../recoil/commonState";

const DiaryPreviewContent = ({ diaries }) => {

const [tripId, setTripId] = useRecoilState(tripIdState);

Check warning on line 14 in src/components/common/DiaryPreviewContent.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'tripId' is assigned a value but never used
const [diaryId, setDiaryId] = useRecoilState(diaryIdState);

Check warning on line 15 in src/components/common/DiaryPreviewContent.js

View workflow job for this annotation

GitHub Actions / build (18.x)

'diaryId' is assigned a value but never used
const navigate = useNavigate();
const [currentSlideIndex, setCurrentSlideIndex] = useState(0);
const sliderRef = useRef(null);
Expand All @@ -31,8 +36,10 @@ const DiaryPreviewContent = ({ diaries }) => {
};

const goToDiary = () => {
const currentDiary = diaries[currentSlideIndex];
navigate("/showdiary", { state: currentDiary.diaryID });
setTripId(diaries[currentSlideIndex].travelID);
setDiaryId(diaries[currentSlideIndex].diaryID);

navigate("/showdiary");
};

let content = null; // 조건부 렌더링을 위한 변수
Expand Down Expand Up @@ -83,6 +90,7 @@ DiaryPreviewContent.propTypes = {
diaryTitle: PropTypes.string.isRequired,
imagePath: PropTypes.string.isRequired,
username: PropTypes.string.isRequired,
travelID: PropTypes.string.isRequired,
}),
).isRequired,
};
Expand Down
1 change: 1 addition & 0 deletions src/components/common/TripCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ TripCalendar.propTypes = {
diaryTitle: PropTypes.string.isRequired,
imagePath: PropTypes.string.isRequired,
username: PropTypes.string.isRequired,
travelID: PropTypes.string.isRequired,
}),
).isRequired,
};
Expand Down
4 changes: 3 additions & 1 deletion src/pages/CalendarPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ const CalendarPage = () => {
axios
.get(`${SERVER_URL}/diary`, { withCredentials: true })
.then((res) => {
console.log(res);
const transformedData = res.data.diarys_info.map((item) => {
return {
date: item.diary.date,
username: item.diary.userName,
diaryTitle: item.diary.title,
imagePath: item.url,
diaryID: item.diary._id
diaryID: item.diary._id,
travelID: item.diary.travel,
};
});
setDiaryInfo(transformedData);
Expand Down
11 changes: 6 additions & 5 deletions src/pages/InviteFriendPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import FriendList from "../components/common/FriendList.js";
import copyIcon from "../assets/icons/copy.svg";
import xicon from "../assets/icons/x-icon.svg";
import BottomNav from "../layout/BottomNav";
import { useNavigate, useLocation } from "react-router-dom";
import { useNavigate } from "react-router-dom";
import Modal from "../components/common/Modal";
import SuccessCopyContent from "../components/common/SuccessCopyContent.js";
import { tripIdState } from "../recoil/commonState";
import { useRecoilValue } from "recoil";

const InviteFriendPage = () => {
const SERVER_URL = process.env.REACT_APP_SERVER_URL;
const navigate = useNavigate();
// navigate 하면서 받은 travel id 값
const { state } = useLocation();
// const travelID = state; <----------------나중에 주석 풀고 다음 줄 지우기
const travelID = "664f3b79e7ecfaede85a7c1f"; // 임시로 쓴 것

Check failure on line 18 in src/pages/InviteFriendPage.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Trailing spaces not allowed
const travelID = useRecoilValue(tripIdState);
// travel의 정보
const [invitecode, setInvitecode] = useState("");

Check failure on line 22 in src/pages/InviteFriendPage.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Trailing spaces not allowed
const [title, setTitle] = useState("");
const [username, setUsername] = useState([]);
const [userimg, setUserimg] = useState([]);
Expand Down
7 changes: 7 additions & 0 deletions src/recoil/commonState.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ export const tripIdState = atom({
key: "tripId",
default: "",
});

export const diaryIdState = atom({
key: "diaryId",
default: "",
});


0 comments on commit d3d6da5

Please sign in to comment.