Skip to content

Commit ac4fa73

Browse files
committed
style: navigate when pressing week
1 parent cdf2b18 commit ac4fa73

File tree

1 file changed

+46
-29
lines changed

1 file changed

+46
-29
lines changed
Lines changed: 46 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,55 @@
1+
"use client";
12
import Link from "next/link";
3+
import { useRouter } from "next/navigation";
24
import { cn } from "utils/merge";
35
import { FaLock } from "react-icons/fa6";
46

57
interface CardProps {
6-
title: string,
7-
description: string,
8-
id: string,
9-
isBlocked: boolean,
10-
bgColor: string,
11-
textColor: string
12-
};
8+
title: string;
9+
description: string;
10+
id: string;
11+
isBlocked: boolean;
12+
bgColor: string;
13+
textColor: string;
14+
}
1315

14-
const WeekCard = ({ title, description, id, isBlocked, bgColor, textColor }: CardProps) => {
16+
const WeekCard = ({
17+
title,
18+
description,
19+
id,
20+
isBlocked,
21+
bgColor,
22+
textColor,
23+
}: CardProps) => {
24+
const router = useRouter();
1525

16-
return (
17-
<div className={cn(bgColor || "bg-blue-500", ' rounded-xl p-4 flex flex-col hover:-translate-y-1 hover:-translate-x-1')}>
18-
<div className="flex flex-row items-center text-white justify-between">
19-
<div className="text-lg font-semibold">
20-
{title}
21-
</div>
22-
{isBlocked && (
23-
<FaLock className="text-xl" />
24-
)}
25-
</div>
26-
<div className="text-white font-extralight pb-5">
27-
{description}
28-
</div>
29-
{!isBlocked && (
30-
<Link href={`week/${id}`} className={`${textColor} bg-white text-sm rounded-full px-3 py-1 w-fit`}>
31-
Check it out
32-
</Link>
33-
)}
34-
</div>
35-
)
36-
}
26+
return (
27+
<div
28+
className={cn(
29+
bgColor || "bg-blue-500",
30+
"flex flex-col rounded-xl p-4 hover:-translate-x-1 hover:-translate-y-1",
31+
)}
32+
onClick={(e) => {
33+
if (!isBlocked) {
34+
router.push(`/week/${id}`);
35+
}
36+
}}
37+
>
38+
<div className="flex flex-row items-center justify-between text-white">
39+
<div className="text-lg font-semibold">{title}</div>
40+
{isBlocked && <FaLock className="text-xl" />}
41+
</div>
42+
<div className="pb-5 font-extralight text-white">{description}</div>
43+
{!isBlocked && (
44+
<Link
45+
href={`week/${id}`}
46+
className={`${textColor} w-fit rounded-full bg-white px-3 py-1 text-sm`}
47+
>
48+
Check it out
49+
</Link>
50+
)}
51+
</div>
52+
);
53+
};
3754

3855
export default WeekCard;

0 commit comments

Comments
 (0)