-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.tsx
More file actions
49 lines (48 loc) · 1.33 KB
/
index.tsx
File metadata and controls
49 lines (48 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use client";
import Link from "next/link";
import styles from "./styles.module.scss";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import {
faEye,
faHeart as regularHeart,
} from "@fortawesome/free-regular-svg-icons";
import { faHeart as solidHeart } from "@fortawesome/free-solid-svg-icons";
import { useAppSelector } from "@/hooks/reduxHook";
interface IProps {
post: IPost;
}
const RecentPostCard = ({ post }: IProps) => {
const user = useAppSelector((state) => state.user);
const date = new Date(post.createdAt);
const formattedDate = date.toLocaleDateString("ko-KR", {
year: "numeric",
month: "long",
day: "numeric",
timeZone: "UTC",
});
return (
<Link
className={`button-card-shadow ${styles.card_resent}`}
href={`/posts/${post.index}`}
passHref
>
<h6>{post.title}</h6>
<div className={styles.item_footer}>
<caption>{formattedDate}</caption>
<div className={styles.icon_container}>
<div>
<FontAwesomeIcon
icon={post.likes.includes(user.id) ? solidHeart : regularHeart}
/>
{post.likes.length}
</div>
<div>
<FontAwesomeIcon icon={faEye} />
{post.views}
</div>
</div>
</div>
</Link>
);
};
export default RecentPostCard;