Skip to content

Commit

Permalink
#559 feat : add mypage queryparameter (#562)
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsikkk authored Nov 5, 2023
1 parent 14d46b4 commit 52abe14
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion src/components/mypage/myInfo/FollowerList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const Follower = () => {
const [total, setTotal] = useState(0);
const [page, setPage] = useState(1);
const [searchParams, setSearchParams] = useSearchParams();
const nickname = localStorage.getItem('nickname');

const GetFollower = async () => {
const response = await request.get('/mypage/follower/', {
Expand All @@ -127,7 +128,8 @@ const Follower = () => {
search_email: searchQuery
});
const params = {
page: page
page: page,
me: nickname
}
if (searchQuery) params.search = searchQuery
setSearchParams(params);
Expand Down
4 changes: 3 additions & 1 deletion src/components/mypage/myInfo/FollowingList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const Following = () => {
const [searchQuery, setSearchQuery] = useState('');
const [refresh, setRefresh] = useState(false);
const [page, setPage] = useState(1);
const nickname = localStorage.getItem('nickname');
const rerender = () => {
setRefresh(!refresh);
}
Expand All @@ -141,7 +142,8 @@ const Following = () => {
search_email: searchQuery
});
const params = {
page: page
page: page,
me: nickname
}
if (searchQuery) params.search = searchQuery
setSearchParams(params);
Expand Down
5 changes: 4 additions & 1 deletion src/components/mypage/myInfo/InfoForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react";
import styled from "styled-components";
import { useCookies } from "react-cookie";
import Loading from "../../common/Loading";
import { useNavigate } from "react-router-dom";
import { useNavigate, useSearchParams } from "react-router-dom";
import Request from "../../../functions/common/Request";
import { Grid } from "@mui/material";
import { Link } from "react-router-dom";
Expand Down Expand Up @@ -177,11 +177,13 @@ export default function InfoForm(props) {
const [loading, setLoading] = useState(true);
const [followerNum, setFollowerNum] = useState(0);
const [followingNum, setFollowingNum] = useState(0);
const [searchParams, setSearchParams] = useSearchParams();
const [myReviewedPlace, setMyReviewedPlace] = useState([]);
const [myStory, setMyStory] = useState([]);
const [myCuration, setMyCuration] = useState([]);
const [myProfileModal, setMyProfileModal] = useState({});
const request = Request(navigate);
const myNickname = localStorage.getItem('nickname');
// 초기에 mypage data 불러오기
const updateMypage = async () => {
const response_info = await request.get("/mypage/me/", null, null);
Expand All @@ -198,6 +200,7 @@ export default function InfoForm(props) {
const response_myStory = await request.get('/mypage/my_story/',null, null);
const response_myReviewPlace = await request.get('/mypage/my_reviewed_place/',null, null);

setSearchParams({me: myNickname});
setMyReviewedPlace(response_myReviewPlace.data.data.results);
setMyStory(response_myStory.data.data.results);
setMyCuration(response_myCuration.data.data);
Expand Down
4 changes: 3 additions & 1 deletion src/components/mypick/mycuration/MyCuration.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ const MyCuration = (props) => {
const navigate = useNavigate();
const request = Request(navigate);
const [page, setPage] = useState(1);
const nickname = localStorage.getItem('nickname');

const onCheckedElement = (checked, item) => {
checked ? setCheckedList([...checkedList, item]) : setCheckedList(checkedList.filter((el) => el !== item));
Expand All @@ -174,7 +175,8 @@ const MyCuration = (props) => {
}, null);

const urlParams = {
page: page
page: page,
me: nickname,
}
if (search) urlParams.search = search

Expand Down
4 changes: 3 additions & 1 deletion src/components/mypick/myplace/Myplace.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const Myplace = () => {
const [checkedList, setCheckedList] = useState('');
const navigate = useNavigate();
const request = Request(navigate);
const nickname = localStorage.getItem('nickname');

// onChange함수를 사용하여 이벤트 감지, 필요한 값 받아오기
const onCheckedElement = (checked, item) => {
Expand All @@ -174,7 +175,8 @@ const Myplace = () => {
}, null);

const urlParams = {
page: page
page: page,
me: nickname
}
if (search) urlParams.search = search
if (checkedList) urlParams.checkedList = checkedList
Expand Down
4 changes: 3 additions & 1 deletion src/components/mypick/mystory/Mystory.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const Mystory = () => {
const navigate = useNavigate();
const request = Request(navigate);
const [page, setPage] = useState(1);
const nickname = localStorage.getItem('nickname');

// onChange함수를 사용하여 이벤트 감지, 필요한 값 받아오기
const onCheckedElement = (checked, item) => {
Expand All @@ -177,7 +178,8 @@ const Mystory = () => {
}, null);

const urlParams = {
page: page
page: page,
me: nickname
}
if (search) urlParams.search = search
if (checkedList) urlParams.checkedList = checkedList
Expand Down

0 comments on commit 52abe14

Please sign in to comment.