Skip to content

Commit

Permalink
Merge pull request #46 from LikeLionHGU/yeji_#45/마이페이지api
Browse files Browse the repository at this point in the history
마이페이지 api 연결 + 문항 수정
  • Loading branch information
skwldwld authored Jun 7, 2024
2 parents 90b91cf + 2940179 commit 307cab7
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 74 deletions.
86 changes: 34 additions & 52 deletions src/routes/mypage/MyPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import styled from "styled-components";
import Header from "../../components/header/header";

import wallpaper from "../../imgs/mywall.jpeg";
import { ReactComponent as Char } from "../../imgs/charimg.svg";
// import Char from "../../imgs/nologimg.svg";
import { ReactComponent as MyBtn } from "../../imgs/mybtn.svg";
import { useNavigate } from "react-router";
import { useEffect, useState } from "react";
Expand Down Expand Up @@ -159,90 +157,72 @@ const MenuBox = styled.div`

export default function MyPage() {
const navigate = useNavigate();
const [data, setData] = useState([]);
const [userName, setuserName] = useState(null);
const [characterName, setcharacterName] = useState(null);
const [characterMyPageImage, setcharacterMyPageImage] = useState(null);
const [userSpicyLevel, setuserSpicyLevel] = useState(null);
const [title, settitle] = useState(null);
const [reviewSpicyLevel, setreviewSpicyLevel] = useState(null);
const [foodName, setfoodName] = useState(null);
const [comment, setcomment] = useState(null);
const [storeId, setstoreId] = useState(null);
const [reviewList, setReviewList] = useState([]);

const [error, setError] = useState();

function toTest() {
navigate("/test");
}

/*useEffect(() => {
useEffect(() => {
fetch(`http://localhost:8080/auth/mypage/memberInfo`, {
redirect: "manual",
credentials: "include",
})
// .then((res) => res.json())
.then((res) => {
console.log(res);
setError(null);
if (res.status === 500) setError("서버 에러");
return res.json();
})
.then((res) => {
console.log(res);
if (res.success) {
setuserName(res.userName);
setcharacterName(res.characterName);
setcharacterMyPageImage(res.characterMyPageImage);
setuserSpicyLevel(res.userSpicyLevel);
}
setuserName(res.userName);
setcharacterName(res.characterName);
setcharacterMyPageImage(res.characterMyPageImage);
setuserSpicyLevel(res.userSpicyLevel);
})
.catch((error) => {
console.error("Error occurred while fetching:", error);
});
}, []);

useEffect(() => {
fetch(`http://localhost:8080/auth/mypage/reviewlist`, {
redirect: "manual",
credentials: "include",
})
.then((res) => res.json())
.then((res) => {
console.log(res);
if (res.success) {
settitle(res.title);
setreviewSpicyLevel(res.reviewSpicyLevel);
setfoodName(res.foodName);
setcomment(res.comment);
setstoreId(res.storeId);
}
setData(res.reviewList);
})
.catch((error) => {
console.error("Error occurred while fetching:", error);
});
}, []);
*/

return (
<>
<Header />
<MyPageContainer>
<Wall>
<WallImg>
{/* <Wallpaper /> */}
<img src={wallpaper} alt="Wallpaper" />
</WallImg>
<ContentContainer>
<CharContainer>
<CharImg>
{/* <img src={characterMyPageImage || Char} alt="Character" /> */}
{/* <img src={characterMyPageImage} /> */}
<Char />
{<img src={characterMyPageImage} alt="Character" />}
</CharImg>
<CharText>
{/* <UserId>{userName}</UserId> */}
<UserId>유저 이름(아이디)</UserId>
<UserId>{userName}</UserId>
<Level>맵기 레벨</Level>
<CharName>5단계 : 실비요정</CharName>
<CharName>{characterName}</CharName>
<CharName>
{userSpicyLevel}단계 : {characterName}
</CharName>
</CharText>
<Btn>
<MyBtn onClick={toTest} />
Expand All @@ -251,23 +231,25 @@ export default function MyPage() {
<ScrollContainer>
<Review>
<RContent>리뷰 내역</RContent>
{/* {reviewList.map((review, index) => ( */}
{/* <ReviewBox key={index}> */}
<ReviewBox>
<Name>음식점 이름 > </Name>
{/* <Name>{title} > </Name> */}
<Detail>
{/* <Fire>불점 {reviewSpicyLevel}개</Fire> */}
<Fire>불점 5개</Fire>
{/* <Date>{review.spicyLevel}</Date> */}
</Detail>
<Menu>
<MenuBox>메뉴 이름 1</MenuBox>
<MenuBox>메뉴 이름 2</MenuBox>
{/* <MenuBox>{foodName}</MenuBox> */}
</Menu>
</ReviewBox>
{/* ))} */}
{data.map((review, index) => (
<ReviewBox key={index}>
<Name>{review.title} > </Name>
<Detail>
<Fire>불점 {review.reviewSpicyLevel}</Fire>
</Detail>
<Menu>
{review.foodName ? (
review.foodName
.split(",")
.map((foodName, idx) => (
<MenuBox key={idx}>{foodName}</MenuBox>
))
) : (
<MenuBox>메뉴 정보 없음</MenuBox>
)}
</Menu>
</ReviewBox>
))}
</Review>
</ScrollContainer>
</ContentContainer>
Expand Down
20 changes: 0 additions & 20 deletions src/routes/result/TestResult.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,6 @@ import styled from "styled-components";
import Fade from "../../components/fade";
import Font from "../../assets/font.css";

import MaepguSmall from "../../imgs/maepgu_small.svg";
import MaepguBig from "../../imgs/maepgu_big.svg";
import MaepguBack from "../../imgs/maepgu_back.svg";

import MaepnoseSmall from "../../imgs/maepnose_small.svg";
import MaepnoseBig from "../../imgs/maepnose_big.svg";
import MaepnoseBack from "../../imgs/maepnose_back.svg";

import MaepmuljuSmall from "../../imgs/maepmulju_small.svg";
import MaepmuljuBig from "../../imgs/maepmulju_big.svg";
import MaepmuljuBack from "../../imgs/maepmulju_back.svg";

import WiamplannerSmall from "../../imgs/wiamplanner_small.svg";
import WiamplannerBig from "../../imgs/wiamplanner_big.svg";
import WiamplannerBack from "../../imgs/wiamplanner_back.svg";

import SlibiFairySmall from "../../imgs/silbifairy_small.svg";
import SlibiFairyBig from "../../imgs/silbifairy_big.svg";
import SlibiFairyBack from "../../imgs/silbifairy_back.svg";
import SlibiFairyBackground from "../../imgs/silbifairy_background.svg";

import DownArrow from "../../imgs/downArrow.svg";
Expand Down Expand Up @@ -163,7 +144,6 @@ const BackImage = styled(Image)`
`;

export default function TestResult() {
// const url = `http://223.p-e.kr:8080/get/survey/result`;
const [data, setData] = useState([]);

const location = useLocation();
Expand Down
4 changes: 2 additions & 2 deletions src/routes/test/Test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ export default function Main() {
"1. 제육 볶음을 먹을때 전혀 매움이 느껴 지지 않는다",
"2. 청양고추도 고추장에 찍어 먹는다",
"3. 집에 붉닭 소스가 있다",
"4. 김치도 물에 헹궈서 먹는다",
"4. 매운 음식을 먹고 우유룰 먹는 사람들은 이해가 가질 않는다",
"5. 매운 음식 때문에 응급실에 실려가도 매운 음식이 땡긴다",
"6. 하루 3끼 매운 음식을 먹을 수 있다",
"7. 매운 음식을 먹으면 스트레스가 풀린다",
"8. 벌칙으로 까나리와 땡초를 고른다면 땡초가 낫다",
"9. 내 이상형은 매운 음식을 잘 먹는 사람이다",
"10. 매운 것을 잘먹는다는 소리를 자주 듣는다",
"11. 친구들이 매운 음식을 먹으러 가자고 하면 불안하다",
"11. 친구들 중 매운 것을 좋아하는 친구가 없으면 마음이 아프다",
"12. 나는 맵기로 유명한 맛집을 다니는 것을 좋아한다 ",
"13. 매운 음식을 주 2회 이상 먹는다",
];
Expand Down

0 comments on commit 307cab7

Please sign in to comment.