-
Notifications
You must be signed in to change notification settings - Fork 94
Expand file tree
/
Copy pathPosts.js
More file actions
90 lines (84 loc) · 2.53 KB
/
Copy pathPosts.js
File metadata and controls
90 lines (84 loc) · 2.53 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
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
import React,{useEffect,useState,useContext} from 'react';
import {useHistory} from 'react-router-dom'
import Heart from '../../assets/Heart';
import './Post.css';
import { FirebaseContext } from '../../store/Context';
import { PostContext } from '../../store/PostContext';
function Posts() {
const {firebase}=useContext(FirebaseContext)
const [products,setProducts]=useState([])
const {setPostDetails}=useContext(PostContext)
const history=useHistory()
useEffect(()=>{
firebase.firestore().collection('products').get().then((snapshot)=>{
const allPost=snapshot.docs.map((product)=>{
return{
...product.data(),
id:product.id
}
})
setProducts(allPost)
})
})
return (
<div className="postParentDiv">
<div className="moreView">
<div className="heading">
<span>Quick Menu</span>
<span>View more</span>
</div>
<div className="cards">
{products.map(product=>{
return <div
className="card"
onClick={()=>{
setPostDetails(product)
history.push('/view')
}}
>
<div className="favorite">
<Heart></Heart>
</div>
<div className="image">
<img src={product.url} alt="" />
</div>
<div className="content">
<p className="rate">₹ {product.price}</p>
<span className="kilometer">{product.category}</span>
<p className="name"> {product.name}</p>
</div>
<div className="date">
<span>{product.createdAt}</span>
</div>
</div>
})
}
</div>
</div>
<div className="recommendations">
<div className="heading">
<span>Fresh recommendations</span>
</div>
<div className="cards">
<div className="card">
<div className="favorite">
<Heart></Heart>
</div>
<div className="image">
<img src="../../../Images/R15V3.jpg" alt="" />
</div>
<div className="content">
<p className="rate">₹ 250000</p>
<span className="kilometer">Two Wheeler</span>
<p className="name"> YAMAHA R15V3</p>
</div>
<div className="date">
<span>10/5/2021</span>
</div>
</div>
</div>
</div>
</div>
);
}
export default Posts;