Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,3 +292,48 @@ export const getPopularContents = async () => {
const res = await GwangjangAxios.get("/contents/contents/like");
return res;
};

//๋‚ด๊ฐ€ ๊ตฌ๋…ํ•œ ์ฃผ์ œ
export const getMySubscribeData = async (accessToken: string) => {
const res = await GwangjangAxios.get("/member/subscribe", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return res;
};

//์ข‹์•„์š”ํ•œ ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธ€
export const getMyLikeCommunityData = async (accessToken: string) => {
const res = await GwangjangAxios.get("/community/mypage", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return res;
};

//๋‚ด๊ฐ€ ์“ด ์ปค๋ฎค๋‹ˆํ‹ฐ ๊ธ€
export const getMyWriteCommunityData = async (accessToken: string) => {
const res = await GwangjangAxios.get("/community/mywrite", {
headers: {
Authorization: `Bearer ${accessToken}`,
},
});
return res;
};

export const postMyLikeContentsData = async (accessToken: string) => {
const res = await GwangjangAxios.post(
"/contents/my-page/like",
{
data: [],
},
{
headers: {
Authorization: `Bearer ${accessToken}`,
},
}
);
return res;
};
6 changes: 4 additions & 2 deletions src/components/atoms/Loading/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import { LoadingBox } from "./style";
const Loading = () => {
return (
<LoadingBox>
<h3>์ž ์‹œ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”.</h3>
<SyncLoader />
<div className="box">
<h3>์ž ์‹œ๋งŒ ๊ธฐ๋‹ค๋ ค์ฃผ์„ธ์š”.</h3>
<SyncLoader />
</div>
</LoadingBox>
);
};
Expand Down
14 changes: 14 additions & 0 deletions src/components/atoms/Loading/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,18 @@ export const LoadingBox = styled.div`
right: 0;
margin: 0 auto;
z-index: 9;
background: rgba(21, 21, 21, 0.7);

.box {
display: flex;
flex-direction: column;
gap: 2rem;
justify-content: space-evenly;
padding: 30px;
width: 300px;
border-radius: 30px;
height: 100px;
align-items: center;
background-color: white;
}
`;
1 change: 0 additions & 1 deletion src/components/atoms/profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ export const LongProfile = ({ nickname, profileImg, date }: ProfileProps) => {
};

export const BigProfile = ({ nickname, profileImg, date }: ProfileProps) => {
profileImg = temp;
const formattedDate = formatDate(date);

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/longTopicBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import bg from "@/assets/discussedTopic/topic1.png";
import { TopicTag } from "@/components/atoms/tag";
import { ToptopicProps, SimilarTopicProps } from "@/types";
import { SimilarTopicProps, ToptopicProps } from "@/types";

import { Container, Top, Bottom, Middle } from "./style";

Expand Down
11 changes: 9 additions & 2 deletions src/components/molecules/mySlideItem/index.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import { useRecoilValue } from "recoil";

import { LikeBorderButton, QuotBorderButton } from "@/components/atoms/button";
import { TopicTag } from "@/components/atoms/tag";
import { ArticleItemProps } from "@/types";
import { myLikeContentsData } from "@/recoil/atoms";
import { ContentsItemProps } from "@/types";

import { SlideWrapper } from "./style";

export const MySlideItem = ({ data }: { data: ArticleItemProps }) => {
export const MySlideItem = ({ data }: { data: ContentsItemProps }) => {
const contentData = useRecoilValue(myLikeContentsData);

console.log("contentData:", contentData);

return (
<SlideWrapper>
<div className="slide-container">
Expand Down
7 changes: 5 additions & 2 deletions src/components/organisms/MyPage/MyContent.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { useRecoilValue } from "recoil";
import styled from "styled-components";

import { MySlideItem } from "@/components/molecules/mySlideItem";
import { articleData } from "@/dummy/articleData";
import { myLikeContentsData } from "@/recoil/atoms";

export const MyContent = () => {
const contentsData = useRecoilValue(myLikeContentsData);

return (
<MyContentWrapper>
{articleData.map((item, idx) => (
{contentsData.map((item, idx) => (
<MySlideItem
key={idx}
data={item}
Expand Down
25 changes: 22 additions & 3 deletions src/components/organisms/MyPage/MyPost.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,33 @@
import { useRecoilValue } from "recoil";
import styled from "styled-components";

import { BigProfile } from "@/components/atoms/profile";
import { MainCommunityBox } from "@/components/molecules/mainCommunityBox";
import { envirData } from "@/dummy/AreaData";
// import { envirData } from "@/dummy/AreaData";
import { myLikeData, myWriteData, selectedTabState } from "@/recoil/atoms";

export const MyPost = () => {
const myLike = useRecoilValue(myLikeData);
// console.log("s", myLike);
const myWrite = useRecoilValue(myWriteData);

const selectedTab = useRecoilValue(selectedTabState);

let data: (typeof myWrite)[number][] | (typeof myLike)[number][] = [];

if (selectedTab === 0) {
data = myWrite;
console.log(data);
} else if (selectedTab === 2) {
data = myLike;
}

console.log("๋ฐ์ดํ„ฐ:", data);

return (
<Container>
{envirData.map((item, idx) => (
<MyPostWrapper>
{data.map((item, idx) => (
<MyPostWrapper key={idx}>
<BigProfile
nickname={item.nickname}
date={item.date}
Expand Down
8 changes: 6 additions & 2 deletions src/components/organisms/MyPage/MySideBox.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
import { useState } from "react";

import { useRecoilValue } from "recoil";
import styled from "styled-components";

import temp from "@/assets/main_logo.svg";
import editNicknameImg from "@/assets/myPage/edit-pencil-nickname.svg";
import editImg from "@/assets/myPage/edit-pencil.svg";
import { TopTopicBox } from "@/components/molecules/longTopicBox";
import { SideBox } from "@/components/molecules/sideBox";
import { MySubscribeData } from "@/dummy/MySubscribeData";
import { mySubscribeTopicData } from "@/recoil/atoms";

export const MySideBox = () => {
const [isEditing, setIsEditing] = useState(false);

const mySubData = useRecoilValue(mySubscribeTopicData);
console.log("ss", mySubData);
const [newNickname, setNewNickname] = useState("๊ธฐ๋ณธ๊ฐ’");

//๋‹‰๋„ค์ž„ ์ˆ˜์ • ์‹œ
Expand Down Expand Up @@ -98,7 +102,7 @@ export const MySideBox = () => {
<div className="subscribe-title">๊ตฌ๋…ํ•œ ์‚ฌํšŒ์ด์Šˆ</div>
<p> ์‚ฌํšŒ์ด์Šˆ ํ‚ค์›Œ๋“œ๋Š” ์ตœ๋Œ€ 3๊ฐœ๊นŒ์ง€ ๊ตฌ๋…ํ•  ์ˆ˜ ์žˆ์–ด์š”.</p>
<div className="subscribe-topic">
{MySubscribeData.map((item, idx) => {
{mySubData.map((item, idx) => {
return (
<div className="topic-wrapper">
<TopTopicBox
Expand Down
64 changes: 62 additions & 2 deletions src/pages/RealMyPage.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,38 @@
import { useState, useEffect } from "react";

import { useRecoilValue } from "recoil";
import { useRecoilValue, useSetRecoilState } from "recoil";
import styled from "styled-components";

import {
getMyLikeCommunityData,
getMySubscribeData,
getMyWriteCommunityData,
postMyLikeContentsData,
} from "@/apis";
import { ResponsiveSideBox } from "@/components/molecules/responsiveSideBox";
import { MyContent } from "@/components/organisms/MyPage/MyContent";
import { MyPageTitle } from "@/components/organisms/MyPage/MyPageTitle";
import { MyPost } from "@/components/organisms/MyPage/MyPost";
import { MySideBox } from "@/components/organisms/MyPage/MySideBox";
import { MyStatus } from "@/components/organisms/MyPage/MyStatus";
import { selectedTabState } from "@/recoil/atoms";
import {
myLikeContentsData,
myLikeData,
mySubscribeTopicData,
myWriteData,
selectedTabState,
} from "@/recoil/atoms";

export const RealMyPage = () => {
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
const selectedTab = useRecoilValue(selectedTabState);

//
const setSubscribeData = useSetRecoilState(mySubscribeTopicData);
const setLikeData = useSetRecoilState(myLikeData);
const setLikeContents = useSetRecoilState(myLikeContentsData);
const setWriteData = useSetRecoilState(myWriteData);

useEffect(() => {
const handleResize = () => {
setWindowWidth(window.innerWidth);
Expand All @@ -26,6 +44,48 @@ export const RealMyPage = () => {
window.removeEventListener("resize", handleResize);
};
}, []);
const accessToken = window.localStorage.getItem("accessToken");

useEffect(() => {
if (accessToken !== null) {
getMySubscribeData(accessToken)
.then((res) => {
// console.log(res.data.data.subscribeResList);
setSubscribeData(res.data.data.subscribeResList);
})
.catch((err) => {
console.log(err);
});

//
getMyLikeCommunityData(accessToken)
.then((res) => {
// console.log(res.data);
setLikeData(res.data.data);
})
.catch((err) => {
console.log(err);
});

postMyLikeContentsData(accessToken)
.then((res) => {
console.log(res.data);
setLikeContents(res.data.data);
})
.catch((err) => {
console.log(err);
});

getMyWriteCommunityData(accessToken)
.then((res) => {
// console.log("11", res.data);
setWriteData(res.data.data);
})
.catch((err) => {
console.log(err);
});
}
});

return (
<OutWrapper>
Expand Down
17 changes: 17 additions & 0 deletions src/recoil/atoms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ export const topDateState = atom({
default: "",
});

export const mySubscribeTopicData = atom({
key: "src/atoms/auth.tsx-mySubscribeTopicData",
default: [],
});

export const myLikeData = atom({
key: "src/atoms/auth.tsx-myLikeData",
default: [],
});

export const myLikeContentsData = atom({
key: "src/atoms/auth.tsx-myLikeContentsData",
default: [],
});

export const myWriteData = atom({
key: "src/atoms/auth.tsx-myWriteData",
export const ToastState = atom({
// ์ฃผ์ œ๋ฑ” ์ƒ์„ธํŽ˜์ด์ง€ ์ ‘์†์‹œ, ์ฟผ๋ฆฌ์ŠคํŠธ๋ง์˜ ์˜์—ญ๊ฐ’์„ ์ €์žฅ
key: "src/atoms/auth.tsx-ToastState ",
Expand Down
21 changes: 21 additions & 0 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,27 @@ export interface BubbleGraphProps {
name: string;
}

export interface SubscribeDataProps {
//
imgUrl: string;
issue: string;
issueId: number;
topic: string;
}

export interface ContentsItemProps {
contents_id: number;
imgUrl: string;
title: string;
description: string;
type: string;
issueTitle: string;
keyword: string;
pubDate: string;
topic: string;
likeCount?: number;
quotCount?: number;

export interface CommentProps {
topicId: number;
communityId: number;
Expand Down