Skip to content

Commit

Permalink
[feat] #43, #68 마이페이지 데이터 불러오기 및 댓글 기능 구현 중
Browse files Browse the repository at this point in the history
[feat] #43, #68 마이페이지 데이터 불러오기 및 댓글 기능 구현 중
  • Loading branch information
kr-nius authored Dec 1, 2023
2 parents 6c95357 + cc8f075 commit 7af2d4d
Show file tree
Hide file tree
Showing 11 changed files with 267 additions and 91 deletions.
17 changes: 12 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@mui/material": "^5.14.18",
"@types/jsonwebtoken": "^9.0.5",
"axios": "^1.6.2",
"base-64": "^1.0.0",
"bcryptjs": "^2.4.3",
"cookie": "^0.6.0",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.2",
Expand All @@ -27,6 +27,7 @@
"sass": "^1.69.5"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/js-cookie": "^3.0.6",
"@types/node": "^20",
"@types/react": "^18",
Expand Down
12 changes: 7 additions & 5 deletions src/app/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ export default function Detail(): JSX.Element {
const fetchData = async () => {
try {
const response = await axios.get(
// `https://www.jerneithe.site/board/detail/${boardDetail.boardId}`,
"https://www.jerneithe.site/board/detail/15",
`https://www.jerneithe.site/board/detail/${boardDetail.boardId}`,
);
setBoardDetail(response.data);
} catch (error) {
Expand Down Expand Up @@ -109,7 +108,8 @@ export default function Detail(): JSX.Element {
{decoded_nickName === boardDetail.nickName && (
<div
onClick={toggleDropdown}
className="ml-auto flex flex-col items-center">
className="ml-auto flex flex-col items-center"
>
<Image
src="/images/more.svg"
alt="etc"
Expand All @@ -121,12 +121,14 @@ export default function Detail(): JSX.Element {
<div className="dropdown absolute mt-7 z-10">
<button
onClick={handleEdit}
className="block w-full text-left py-2 px-4 hover:bg-gray-200 focus:outline-none">
className="block w-full text-left py-2 px-4 hover:bg-gray-200 focus:outline-none"
>
수정
</button>
<button
onClick={handleDelete}
className="block w-full text-left py-2 px-4 hover:bg-gray-200 focus:outline-none">
className="block w-full text-left py-2 px-4 hover:bg-gray-200 focus:outline-none"
>
삭제
</button>
</div>
Expand Down
33 changes: 23 additions & 10 deletions src/app/mypage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,23 @@ export default function Mypage() {

const response = await axios.post(
`https://www.jerneithe.site/user/api/profile`,
{ email: "user94@test.com" }
{ email: "user95@test.com" }
);
setUserProfile(response.data);

// 비밀번호 디코딩
let pw_jwt: string = response.data.password;
// console.log("회원정보 pw: ", response.data.password);
// let pw_jwt = response.data.password;
// let pw_payload = pw_jwt.substring(
// pw_jwt.indexOf(".") + 1,
// pw_jwt.lastIndexOf(".")
// );

// console.log("pw_payload: ", pw_payload);

// let pw_decode = base64.decode(pw_payload);

// console.log("pw 디코딩: ", pw_decode);

// 기존 것
// let password_jwt: string = response.data.password;
Expand All @@ -112,30 +123,28 @@ export default function Mypage() {
// const decoded_password = decodedPass?.sub;
// setPassword(decoded_password);

console.log("postData: ", response.data);
console.log("회원정보 Data: ", response.data);
} catch (error) {
console.error("회원정보 에러: ", error);
}
};
profileData();
}, []);

// ---------------------------------------------------------
// ------------------------------------------------------------------------

// board 이미지 데이터 불러오기
useEffect(() => {
const postData = async () => {
const req = await axios.get("https://www.jerneithe.site/board/list");
const data: FEEDATA[] = req.data;
const filteredData = data.filter((item) => item.nickName === "dongdong");
const filteredData = data.filter((item) => item.nickName === "테스터");
console.log("filterData: ", filteredData);
setMyPostData(filteredData);
};
postData();
}, []);

console.log("디코딩 비번: ", password);

// 회원 정보 수정 모달 이벤트
const handleSettingsClick = () => {
setShowProfileModify(!showProfileModify);
Expand All @@ -155,12 +164,16 @@ export default function Mypage() {
{/* ------------- 프로필 부분 ------------- */}
{userPofile && (
<>
<MypageProfile nickname={userPofile.nickname} />
<MypageProfile
nickname={userPofile.nickname}
postnum={myPostData.length}
myPostData={myPostData}
/>
</>
)}
{/* --------------------------------------- */}
{/* ------------- tap 부분 ------------- */}
<TabBar myPostData={myPostData} />
{/* <TabBar myPostData={myPostData} /> */}
</div>
<Menubar />
</div>
Expand All @@ -177,7 +190,7 @@ export default function Mypage() {
handleSettingsClick={handleSettingsClick}
email={userPofile.email}
name={userPofile.name}
password={password}
password={userPofile.password}
/>
)}
</>
Expand Down
Loading

0 comments on commit 7af2d4d

Please sign in to comment.