-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomePagePostCard.jsx
107 lines (102 loc) · 3.88 KB
/
HomePagePostCard.jsx
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
import React from 'react';
import styles from '../css/posts.module.css';
import { useRouter } from 'next/router';
import Image from 'next/image';
import { GoCommentDiscussion } from 'react-icons/go';
import profilePlaceholder from '../images/profilePlaceholder.png';
import moment from 'moment/moment';
import { useAuthContext } from '../hooks/useAuthContext';
import languageIcons from '../util/languageIcons';
export default function HomePagePostCard({ post, replyCountByPostId }) {
const router = useRouter();
const { postId } = router.query;
const replyCountObject = Object.assign({}, ...replyCountByPostId);
const { user } = useAuthContext();
const dateObject = moment(post.postTime);
const readableDate = dateObject.fromNow();
return (
<div className="w-11/12 md:w-3/4 my-[10px] border border-[#eaeaea] rounded-[10px] p-5 drop-shadow-md ">
<div className="flex">
<div className="flex flex-col w-full h-1/5 md:flex-row md:gap-[15px]">
<div className="flex justify-between md:block md:self-start w-full sm:w-auto">
{post.photoURL ? (
<Image
src={post.photoURL}
width={60}
height={60}
alt="profile"
className="rounded-full w-[60px] h-[60px]"
onClick={() => {
router.push(`/users/${post.user}`);
}}
/>
) : (
<Image
src={profilePlaceholder}
alt="profile"
className="rounded-full w-[60px] h-[60px]"
onClick={() => {
router.push(`/users/${post.user}`);
}}
/>
)}
<div className="flex md:hidden self-end text-[40px]">
{languageIcons[post.programmingLanguage.toLowerCase()]}
</div>
</div>
<div className=" w-full h-full pt-[20px] text-[10px] md:w-[60%] md:text-[16px]">
<div className="flex items-start">
<div
onClick={() => {
router.push(`/users/${post.user}`);
}}
className="font-bold mx-[5px] cursor-pointer"
>
<span className="text-[#4f9cf9]">@{post.user}</span> in
</div>
<div className="font-bold mr-[5px] text-[#94a3b8]">
{post.programmingLanguage}
</div>
<div className="font-bold mr-[5px] text-[#94a3b8]">
<span className="text-black">{readableDate}</span>
</div>
</div>
<div className={styles.details}>
<div>
<div
className="font-bold text-3xl mt-2.5 mb-1 cursor-pointer"
onClick={() => {
router.push(`/posts/${post.postId}`);
}}
>
{post.postTitle}
</div>
</div>
<div>
<div>
Availability: {post.weekDayAvailability}{' '}
{post.dailyAvailability}{' '}
</div>
<div>Time zone: {post.timeZone}</div>
</div>
</div>
</div>
<div className="hidden md:flex w-1/3 justify-end text-[50px]">
{languageIcons[post.programmingLanguage.toLowerCase()]}
</div>
</div>
</div>
<div className={styles.replies}>
<div>
<GoCommentDiscussion
className="text-2xl ml-1.2 text-[#52525b] md:ml-[80px] cursor-pointer"
onClick={() => {
router.push(`/posts/${post.postId}#comments`);
}}
/>
</div>
<div>{replyCountObject[post.postId]}</div>
</div>
</div>
);
}