Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/#77/community api #79

Merged
merged 8 commits into from
Nov 23, 2023
Merged
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
19 changes: 17 additions & 2 deletions src/apis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,26 @@ export const putKakaoRegister = async ({
};

export const getCommunityAllData = async () => {
const res = await GwangjangAxios.get("/community");
const res = await GwangjangAxios.get("/community/");
return res;
};

export const getCommunityAreaData = async (topicId: number) => {
export const getCommunityAreaData = async (topicId: string) => {
const res = await GwangjangAxios.get(`/community/topic/${topicId}`);
return res;
};

export const getSubscribeTop5 = async () => {
const res = await GwangjangAxios.get("/member/subscribe/issue");
return res;
};

export const getCommunityDetailData = async (topicId: number, communityId: number) => {
const res = await GwangjangAxios.get(`/community/topic/${topicId}/community/${communityId}`);
return res;
};

export const getCommunityTop5 = async () => {
const res = await GwangjangAxios.get("/community/?sortBy=ALL/");
return res;
};
4 changes: 2 additions & 2 deletions src/components/atoms/tag/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ export const TopicTag = ({ category }: { category: string }) => {
return <Tag $category={category}>{category}</Tag>;
};

export const KeywordTag = ({ category }: { category: string }) => {
return <Keyword $category={category}>{category}</Keyword>;
export const KeywordTag = ({ category, children }: { category: string; children: string }) => {
return <Keyword $category={category}>{children}</Keyword>;
};
12 changes: 7 additions & 5 deletions src/components/atoms/tag/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ export const Tag = styled.div<{ $category: string }>`
align-items: center;
border-radius: 55px;
background: ${(props) =>
props.$category === "์ผ์ž๋ฆฌยท๋…ธ๋™"
props.$category === "์ผ์ž๋ฆฌ-๋…ธ๋™"
? "var(--Main_Blue)"
: props.$category === "์ฃผ๊ฑฐ"
: props.$category === "์ฃผ๊ฑฐ-์‚ฌํšŒ์•ˆ์ „๋ง"
? "var(--Sub_Purple)"
: props.$category === "ํ™˜๊ฒฝ"
? "var(--Main_NeonGreen)"
: "var(--Sub_Orange)"};
: props.$category === "๊ต์œก"
? "var(--Sub_Orange)"
: "white"};

//text
color: var(--Gray1_50, #fafafa);
Expand All @@ -31,9 +33,9 @@ export const Keyword = styled.div<{ $category: string }>`
align-items: center;
border-radius: 55px;
color: ${(props) =>
props.$category === "์ผ์ž๋ฆฌยท๋…ธ๋™"
props.$category === "์ผ์ž๋ฆฌ-๋…ธ๋™"
? "var(--Main_Blue)"
: props.$category === "์ฃผ๊ฑฐ"
: props.$category === "์ฃผ๊ฑฐ-์‚ฌํšŒ์•ˆ์ „๋ง"
? "var(--Sub_Purple)"
: props.$category === "ํ™˜๊ฒฝ"
? "var(--Main_NeonGreen)"
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/PreviewCommunityBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const PreviewCommunityBox = ({ data }: { data: CommunityItemProps }) => {
</div>
<div className="bottom-content">
<div>์ธ์šฉํ•œ ์ฝ˜ํ…์ธ </div>
<p>{data.quotText}</p>
<p>{data.contentsTitle}</p>
</div>
</CommunityDetailContainer>
</>
Expand Down
22 changes: 17 additions & 5 deletions src/components/molecules/detailCommunityBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { CommunityItemProps } from "@/types";
import { CommunityPostContainer } from "./style";

export const DetailCommunityBox = ({ data }: { data: CommunityItemProps }) => {
const contLen = String(data.contents).length;

return (
<CommunityPostContainer>
<div className="top-post-wrapper">
Expand All @@ -22,18 +24,28 @@ export const DetailCommunityBox = ({ data }: { data: CommunityItemProps }) => {
<div className="top-wrapper">
<div className="content-category">
<TopicTag category={data.area} />
{/* <KeywordTag category={data.subject} /> */}
<KeywordTag category={data.keyword} />
<KeywordTag category={data.area}>{data.subject}</KeywordTag>
<KeywordTag category={data.area}>{data.keyword}</KeywordTag>
</div>
<div className="content-text">{data.communityText} </div>
</div>
<div className="content-quot">
<div
className="content-quot"
onClick={() => {
if (contLen > 20) {
console.log(contLen);
window.open(`${data.contents}`);
} else {
window.open(`https://www.youtube.com/watch?v=${data.contents}`);
}
}}
>
<div className="quot-text">
<p>์ธ์šฉํ•œ ์ฝ˜ํ…์ธ </p>
<div>{data.quotText}</div>
<div>{data.contentsTitle}</div>
</div>
<img
src="https://images.chosun.com/resizer/XKL6ePOdAuAn81yF-ZBOY8VyQWs=/616x0/smart/cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/JMI3RCEB2Y7QSIUWJKT2MT7CC4.jpg"
src={data.contentsUrl}
alt=""
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions src/components/molecules/longTopicBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const SimilarTopicBox = ({ data }: { data: SimilarTopicProps }) => {
<TopicTag category={data.area} />
</Top>
<Bottom>
<p>{data.subscibeCount}๋ช…</p>์ด ๊ตฌ๋…ํ•˜๊ณ  ์žˆ์–ด์š”
<p>{data.subscribeCount}๋ช…</p>์ด ๊ตฌ๋…ํ•˜๊ณ  ์žˆ์–ด์š”
</Bottom>
</Container>
);
Expand All @@ -36,8 +36,8 @@ export const TopTopicBox = ({ data }: { data: ToptopicProps }) => {
$string="top"
>
<Middle>
<div className="title">{data.subject}</div>
<TopicTag category={data.area} />
<div className="title">{data.title}</div>
<TopicTag category={data.category} />
</Middle>
</Container>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/main/communitybox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ export const CommunityBox = () => {
<div className="community-content">
<div className="community-tag-wrapper">
<TopicTag category={item.area} />
<KeywordTag category={item.keyword} />
<KeywordTag category={item.area}>{item.topic}</KeywordTag>
<KeywordTag category={item.area}>{item.keyword}</KeywordTag>
</div>
<div className="content-wrapper">
<div className="content-text">{item.communityText}</div>
Expand Down
45 changes: 39 additions & 6 deletions src/components/molecules/mainCommunityBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,60 @@
import { useNavigate } from "react-router";

import { CommentBorderButton, LikeBorderButton } from "@/components/atoms/button";
import { KeywordTag, TopicTag } from "@/components/atoms/tag";
import { CommunityItemProps } from "@/types";

import { CommunityMainContainer } from "./style";

export const MainCommunityBox = ({ data }: { data: CommunityItemProps }) => {
let topicId = 0;

const contLen = String(data.contents).length;

if (data.area === "์ผ์ž๋ฆฌ-๋…ธ๋™") {
topicId = 1;
} else if (data.area === "์ฃผ๊ฑฐ-์‚ฌํšŒ์•ˆ์ „๋ง") {
topicId = 2;
} else if (data.area === "ํ™˜๊ฒฝ") {
topicId = 3;
} else if (data.area === "๊ต์œก") {
topicId = 4;
}

const navigate = useNavigate();

const SpaceTo = (page: string) => {
navigate(page);
};

return (
<CommunityMainContainer>
<CommunityMainContainer onClick={() => SpaceTo(`/detailcommunity/${topicId}/${data.id}`)}>
<div className="top-wrapper">
<div className="content-category">
<TopicTag category={data.area} />
{/* <KeywordTag category={data.} /> */}
<KeywordTag category={data.keyword} />
<KeywordTag category={data.area}>{data.subject}</KeywordTag>
<KeywordTag category={data.area}>{data.keyword}</KeywordTag>
</div>
<div className="content-text">{data.communityText}</div>
</div>
<div className="content-quot">
<div
className="content-quot"
onClick={(e) => {
e.stopPropagation();
if (contLen > 20) {
console.log(contLen);
window.open(`${data.contents}`);
} else {
window.open(`https://www.youtube.com/watch?v=${data.contents}`);
}
}}
>
<div className="quot-text">
<p>์ธ์šฉํ•œ ์ฝ˜ํ…์ธ </p>
<div>{data.quotText}</div>
<div>{data.contentsTitle}</div>
</div>
<img
src="https://images.chosun.com/resizer/XKL6ePOdAuAn81yF-ZBOY8VyQWs=/616x0/smart/cloudfront-ap-northeast-1.images.arcpublishing.com/chosun/JMI3RCEB2Y7QSIUWJKT2MT7CC4.jpg"
src={data.contentsUrl}
alt=""
/>
</div>
Expand Down
3 changes: 2 additions & 1 deletion src/components/molecules/mainCommunityBox/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const CommunityMainContainer = styled.div`
box-shadow: 0px 15px 35px 0px rgba(66, 66, 66, 0.05);
padding: 20px 24px;
box-sizing: border-box;
cursor: pointer;

.top-wrapper {
display: flex;
Expand Down Expand Up @@ -46,7 +47,7 @@ export const CommunityMainContainer = styled.div`
border-radius: 5px;
background: var(--Gray2_100, #f5f5f5);
border-radius: 5px;

cursor: pointer;
display: flex;

.quot-text {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import styled from "styled-components";

import bg from "@/assets/DetailTitle/detail-background.png";
import { DetailCommunityBox } from "@/components/molecules/detailCommunityBox";
import { envirData } from "@/dummy/AreaData";
import { CommunityItemProps } from "@/types";

const DetailCommunityTitle = () => {
const DetailCommunityTitle = ({ data }: { data: CommunityItemProps }) => {
return (
<Container>
<img
Expand All @@ -13,7 +13,7 @@ const DetailCommunityTitle = () => {
width="100%"
height={220}
/>
<DetailCommunityBox data={envirData[0]} />
<DetailCommunityBox data={data} />
</Container>
);
};
Expand Down
22 changes: 22 additions & 0 deletions src/dummy/AreaData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export const envirData = [
commentCount: 0,
contentsId: 3,
contents: null,
contentsUrl: "sdf",
contentsTitle: "sdfsjleifjdlijf",
likeStatus: "false",
quotText: "asidjfaiejfaidjfiajeifj",
},
Expand All @@ -28,8 +30,10 @@ export const envirData = [
area: "ํ™˜๊ฒฝ",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
keyword: "ํ•˜์ด",
contentsUrl: "sdf",
likeCount: 1,
commentCount: 0,
contentsTitle: "sdfsjleifjdlijf",
contentsId: 3,
contents: null,
likeStatus: "false",
Expand All @@ -46,7 +50,9 @@ export const envirData = [
area: "ํ™˜๊ฒฝ",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
keyword: "ํ•˜์ด",
contentsUrl: "sdf",
likeCount: 1,
contentsTitle: "sdfsjleifjdlijf",
commentCount: 0,
contentsId: 3,
contents: null,
Expand All @@ -62,8 +68,10 @@ export const envirData = [
nickname: "nkcikname",
profileImg: "profile",
area: "ํ™˜๊ฒฝ",
contentsUrl: "sdf",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
keyword: "ํ•˜์ด",
contentsTitle: "sdfsjleifjdlijf",
likeCount: 1,
commentCount: 0,
contentsId: 3,
Expand All @@ -81,6 +89,8 @@ export const envirData = [
profileImg: "profile",
area: "ํ™˜๊ฒฝ",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
contentsUrl: "sdf",
contentsTitle: "sdfsjleifjdlijf",
keyword: "ํ•˜์ด",
likeCount: 1,
commentCount: 0,
Expand All @@ -98,6 +108,8 @@ export const envirData = [
nickname: "nkcikname",
profileImg: "profile",
area: "ํ™˜๊ฒฝ",
contentsUrl: "sdf",
contentsTitle: "sdfsjleifjdlijf",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
keyword: "ํ•˜์ด",
likeCount: 1,
Expand All @@ -112,11 +124,13 @@ export const envirData = [
communityText:
"์ฃ„์†กํ•œ ๋งˆ์Œ์„ ๋‹ด์•„ โค๏ธ ์ž‘๊ณก ์ž‘์‚ฌ๋ฅผ ํ•ด ๋ณด์•˜์–ด์š” ๐Ÿ’• ์ •๋ง ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค ๐Ÿ˜‰ ์˜ˆ์˜๊ฒŒ ๋“ค์–ด ์ฃผ์„ธ์š” ๐Ÿ’– ์˜๋ฆฌ ์˜๋ฆฌ ์•” ์˜๋ฆฌ ๐ŸŽต ๋‚ด๊ฐ€ ๋ฏธ์•ˆํ•ด ๐ŸŽ™๐ŸŽ™ ํ•œ๋ฒˆ๋งŒ ๋ด์ค˜! ๐Ÿ˜˜ ์ด์˜๊ฒŒ ๋ด์ค˜์ž‰~ ๐Ÿ˜ ๋Œ์•„์™€์ค˜! โฃ๏ธ ์‚ฌ๋ž‘ํ•ด์ค˜~~ ๐ŸŽค๐ŸŽถ๐ŸŽถ๐ŸŽต ์ฃ„์†กํ•œ ๋งˆ์Œ์„ ๋‹ด์•„ โค๏ธ ์ž‘๊ณก ์ž‘์‚ฌ๋ฅผ ํ•ด ๋ณด์•˜์–ด์š” ๐Ÿ’• ์ •๋ง ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค ๐Ÿ˜‰ ์˜ˆ์˜๊ฒŒ ๋“ค์–ด ์ฃผ์„ธ์š” ๐Ÿ’– ์˜๋ฆฌ ์˜๋ฆฌ ์•” ์˜๋ฆฌ ๐ŸŽต ๋‚ด๊ฐ€ ๋ฏธ์•ˆํ•ด ๐ŸŽ™๐ŸŽ™ ํ•œ๋ฒˆ๋งŒ ๋ด์ค˜! ๐Ÿ˜˜ ์ด์˜๊ฒŒ ๋ด์ค˜์ž‰~ ๐Ÿ˜ ๋Œ์•„์™€์ค˜! โฃ๏ธ ์‚ฌ๋ž‘ํ•ด์ค˜~~ ๐ŸŽค๐ŸŽถ๐ŸŽถ๐ŸŽต ์ฃ„์†กํ•œ ๋งˆ์Œ์„ ๋‹ด์•„ โค๏ธ ์ž‘๊ณก ์ž‘์‚ฌ๋ฅผ ํ•ด ๋ณด์•˜์–ด์š” ๐Ÿ’• ์ •๋ง ์ฃ„์†กํ•ฉ๋‹ˆ๋‹ค ๐Ÿ˜‰ ์˜ˆ์˜๊ฒŒ ๋“ค์–ด ์ฃผ์„ธ์š” ๐Ÿ’– ์˜๋ฆฌ ์˜๋ฆฌ ์•” ์˜๋ฆฌ ๐ŸŽต ๋‚ด๊ฐ€ ๋ฏธ์•ˆํ•ด ๐ŸŽ™๐ŸŽ™ ํ•œ๋ฒˆ๋งŒ ๋ด์ค˜!",
date: "2023-11-13T12:20:59.176275",
contentsUrl: "sdf",
writerId: "LOCAL-2341",
nickname: "nkcikname",
profileImg: "profile",
area: "ํ™˜๊ฒฝ",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
contentsTitle: "sdfsjleifjdlijf",
keyword: "ํ•˜์ด",
likeCount: 1,
commentCount: 0,
Expand All @@ -135,7 +149,9 @@ export const envirData = [
profileImg: "profile",
area: "ํ™˜๊ฒฝ",
subject: "ํ›„์ฟ ์‹œ๋งˆ ์˜ค์—ผ์ˆ˜",
contentsUrl: "sdf",
keyword: "ํ•˜์ด",
contentsTitle: "sdfsjleifjdlijf",
likeCount: 1,
commentCount: 0,
contentsId: 3,
Expand All @@ -150,12 +166,14 @@ export const EduData = [
id: 7,
communityText: "์ด์•ผ๊ธฐ",
date: "2023-11-13T12:20:59.176275",
contentsTitle: "sdfsjleifjdlijf",
writerId: "LOCAL-2341",
nickname: "nkcikname",
profileImg: "profile",
area: "๊ต์œก",
subject: "๊ต์œก์–ด์ฉŒ๊ตฌ",
keyword: "ํ•˜์ด",
contentsUrl: "sdf",
likeCount: 1,
commentCount: 0,
contentsId: 3,
Expand All @@ -169,11 +187,13 @@ export const EduData = [
date: "2023-11-13T12:20:59.176275",
writerId: "LOCAL-2341",
nickname: "nkcikname",
contentsTitle: "sdfsjleifjdlijf",
profileImg: "profile",
area: "๊ต์œก",
subject: "๊ต์œก์–ด์ฉŒ๊ตฌ",
keyword: "ํ•˜์ด",
likeCount: 1,
contentsUrl: "sdf",
commentCount: 0,
contentsId: 3,
contents: null,
Expand All @@ -188,6 +208,8 @@ export const EduData = [
nickname: "nkcikname",
profileImg: "profile",
area: "๊ต์œก",
contentsUrl: "sdf",
contentsTitle: "sdfsjleifjdlijf",
subject: "๊ต์œก์–ด์ฉŒ๊ตฌ",
keyword: "ํ•˜์ด",
likeCount: 1,
Expand Down
Loading