Skip to content

Commit 5771b0c

Browse files
committed
feat: related article router push
1 parent d4983b1 commit 5771b0c

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/components/learning/SubscriptionBanner.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import { useRouter } from 'next/navigation';
12
import React from 'react';
23

34
const SubscriptionBanner = () => {
5+
const router = useRouter();
6+
47
return (
58
<div className="w-full flex items-center justify-between bg-gradient-to-r from-gray-50 to-gray-100 rounded-2xl px-12 py-16 shadow-md max-w-[1000px] mx-auto mt-12">
69
<div className="text-left">
@@ -10,7 +13,8 @@ const SubscriptionBanner = () => {
1013
</h2>
1114
</div>
1215
<div>
13-
<button className="bg-gradient2 px-8 py-4 rounded-full shadow-md hover:bg-gradient2 text-neutral-50 text-lg font-bold font-['Inter'] transition duration-300 ">
16+
<button className="bg-gradient2 px-8 py-4 rounded-full shadow-md hover:bg-gradient2 text-neutral-50 text-lg font-bold font-['Inter'] transition duration-300"
17+
onClick={() => router.push('/payment')}>
1418
첫달 무료 구독하기
1519
</button>
1620
</div>

src/components/learning/article/RelatedArticles.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@ import { RelatedArticle } from "@/types/learning";
33
import Image from "next/image";
44
import { getRelatedArticles } from "@/factory/Article/GetArticle";
55
import { getValidImageSrc } from "@/utils/checkImageProperty";
6+
import { useRouter } from "next/navigation";
67

78
interface RelatedArticlesProps {
89
articleId: number;
910
}
1011

1112
const RelatedArticles = ({ articleId }: RelatedArticlesProps) => {
13+
const router = useRouter();
1214
const [relatedArticles, setRelatedArticles] = useState<RelatedArticle[] | string>("");
1315

1416
useEffect(() => {
@@ -25,6 +27,10 @@ const RelatedArticles = ({ articleId }: RelatedArticlesProps) => {
2527
fetchData();
2628
}, [articleId]);
2729

30+
const handleContentClick = (item: any) => {
31+
router.push(`/learning/detail/${item.article.articleId}`);
32+
};
33+
2834
// 데이터가 없을 때 처리
2935
if (typeof relatedArticles === "string") {
3036
return (
@@ -44,7 +50,8 @@ const RelatedArticles = ({ articleId }: RelatedArticlesProps) => {
4450
</h2>
4551
<div className="grid grid-cols-3 gap-4">
4652
{relatedArticles.map((item) => (
47-
<div key={item.article.articleId} className="flex flex-col justify-between h-full">
53+
<div key={item.article.articleId} className="flex flex-col justify-between h-full cursor-pointer"
54+
onClick={() => handleContentClick(item)}>
4855
<div
4956
className="w-full relative overflow-hidden rounded-[25px]"
5057
style={{ aspectRatio: "409 / 255" }}

0 commit comments

Comments
 (0)