diff --git a/apps/member/src/components/common/Card/Card.tsx b/apps/member/src/components/common/Card/Card.tsx deleted file mode 100644 index 6ada4a14..00000000 --- a/apps/member/src/components/common/Card/Card.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import { useNavigate } from 'react-router-dom'; -import Image from '../Image/Image'; -import { createImageUrl } from '@utils/api'; -import classNames from 'classnames'; - -interface CardProps { - to?: string; - image?: string; - title: string; - description?: string; -} - -const Card = ({ to, image, title, description }: CardProps) => { - const navigate = useNavigate(); - - const handleCardClick = () => { - to && navigate(to); - }; - - return ( -
- {image && ( - {title} - )} -
-

- {title} -

- {description && ( -

{description}

- )} -
-
- ); -}; - -export default Card; diff --git a/apps/member/src/components/common/PostCard/PostCard.tsx b/apps/member/src/components/common/PostCard/PostCard.tsx new file mode 100644 index 00000000..10f27a4c --- /dev/null +++ b/apps/member/src/components/common/PostCard/PostCard.tsx @@ -0,0 +1,48 @@ +import { useCallback } from 'react'; +import { useNavigate } from 'react-router-dom'; +import { createImageUrl } from '@utils/api'; +import { cn } from '@utils/string'; +import Image from '../Image/Image'; + +interface PostCardProps { + to: string; + title: string; + subTitle?: string; + imageUrl?: string; +} + +const PostCard = ({ to, title, subTitle, imageUrl }: PostCardProps) => { + const navigate = useNavigate(); + + const handleClick = useCallback(() => navigate(to), [navigate, to]); + + return ( +
+ {title} +
+

+ {title} +

+ {subTitle && ( +

{subTitle}

+ )} +
+
+ ); +}; + +export default PostCard; diff --git a/apps/member/src/components/main/BlogSection/BlogSection.tsx b/apps/member/src/components/main/BlogSection/BlogSection.tsx new file mode 100644 index 00000000..4e32f809 --- /dev/null +++ b/apps/member/src/components/main/BlogSection/BlogSection.tsx @@ -0,0 +1,27 @@ +import { useBlog } from '@hooks/queries'; +import Section from '@components/common/Section/Section'; +import { COMMUNITY_MESSAGE } from '@constants/message'; +import PostCard from '@components/common/PostCard/PostCard'; +import { PATH } from '@constants/path'; +import EmptyBox from '@components/common/EmptyBox/EmptyBox'; + +const BlogSection = () => { + const { data } = useBlog(); + + return ( +
+ + + {data.items.length === 0 ? ( + {COMMUNITY_MESSAGE.NO_ARTICLE} + ) : ( + data.items.map((news) => ( + + )) + )} + +
+ ); +}; + +export default BlogSection; diff --git a/apps/member/src/components/main/NewsCardSection/NewsCardSection.tsx b/apps/member/src/components/main/NewsCardSection/NewsCardSection.tsx deleted file mode 100644 index 32153bba..00000000 --- a/apps/member/src/components/main/NewsCardSection/NewsCardSection.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import Card from '@components/common/Card/Card'; -import Section from '@components/common/Section/Section'; -import { COMMUNITY_MESSAGE } from '@constants/message'; -import { PATH } from '@constants/path'; -import type { BlogPostItem } from '@type/blog'; -import type { CommunityPostItem } from '@type/community'; - -interface NewsCardSectionProps { - to: string; - title: string; - data?: Array; -} - -const NewsCardSection = ({ to, title, data = [] }: NewsCardSectionProps) => { - const post_path = to === PATH.NEWS ? PATH.NEWS : PATH.BLOG; - - return ( -
- - - {data.length === 0 ? ( -

- {COMMUNITY_MESSAGE.NO_ARTICLE} -

- ) : ( - data.map((news, index) => ( - - )) - )} -
-
- ); -}; - -export default NewsCardSection; diff --git a/apps/member/src/components/my/MyActivityGroupSection/MyActivityGroupSection.tsx b/apps/member/src/components/my/MyActivityGroupSection/MyActivityGroupSection.tsx index cd569587..abc5f854 100644 --- a/apps/member/src/components/my/MyActivityGroupSection/MyActivityGroupSection.tsx +++ b/apps/member/src/components/my/MyActivityGroupSection/MyActivityGroupSection.tsx @@ -1,4 +1,4 @@ -import Card from '@components/common/Card/Card'; +import PostCard from '@components/common/PostCard/PostCard'; import Section from '@components/common/Section/Section'; import { PATH_FINDER } from '@constants/path'; import type { ActivityGroupMemberMyType } from '@type/activity'; @@ -13,12 +13,12 @@ const MyActivityGroupSection = ({ data }: MyActivityGroupSectionProps) => { {data.map((activityGroup) => ( - ))}