-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHome.jsx
More file actions
46 lines (41 loc) · 1021 Bytes
/
Home.jsx
File metadata and controls
46 lines (41 loc) · 1021 Bytes
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
import React from 'react'
import services from '../appwrite/Services'
import { useState } from 'react'
import { useEffect } from 'react'
import Container from '../Components/Component/Container'
import Postcard from '../Components/Component/Postcard'
function Home() {
const [posts, setPosts] = useState([])
useEffect(() => {
services.getDocument([]).then((posts) => {
if (posts) {
setPosts(posts.documents)
}
})
}, [])
if (posts.length === 0) {
return (
<div className='w-full py-8'>
<Container>
<div className="flex flex-wrap">
<h1>Login to read posts</h1>
</div>
</Container>
</div>
)
}
return (
<div className='w-full py-8'>
<Container>
<div className="flex flex-wrap">
{posts.map((post) => (
<div className="p-2 w-1/4" key={post.$id}>
<Postcard {...post} />
</div>
))}
</div>
</Container>
</div>
)
}
export default Home