-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBookmarks.tsx
More file actions
111 lines (100 loc) · 3.21 KB
/
Bookmarks.tsx
File metadata and controls
111 lines (100 loc) · 3.21 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { Center, Pagination, Select } from '@mantine/core';
import { useForm } from '@mantine/form';
import { useEffect, useState } from 'react';
import { BsBookmarks, BsSortUpAlt } from 'react-icons/bs';
import { TbTimelineEventText } from 'react-icons/tb';
import Banner from '../../common/Banner';
import Post from '../../common/Post';
import Skeleton from '../../common/Skeleton';
import { POSTS } from '../../constants/dummy';
import Async from '../../containers/Async';
import { formateNumber } from '../../helpers/millify';
import useHelmet from '../../hooks/useHelmet';
function Bookmarks() {
useHelmet('bookmarks');
const posts = POSTS.filter((post) => post.isSaved);
const [activePage, setPage] = useState(1);
const searchForm = useForm({
initialValues: {
filter: 'blogs',
},
});
const onFormSearchFormSubmit = (values: { filter: string }) => {
console.log(values);
};
const [state, setState] = useState({
loading: true,
fulfilled: false,
error: null,
});
useEffect(() => {
const TimerId = setTimeout(() => {
setState({
loading: false,
fulfilled: true,
error: null,
});
}, 2000);
return () => {
clearTimeout(TimerId);
};
}, []);
return (
<>
<Banner
title='Bookmarks'
subtitle={`Bookmarks: ${formateNumber(posts.length)}`}
icon={BsBookmarks}
/>
<Async {...state} skeleton={<Skeleton variant='post' repeat={6} />}>
{posts.length ? (
<>
<div className='shadow-nice flex justify-between mb-10 p-5 bg-white'>
<form
className='md:flex items-center flex-1'
onSubmit={searchForm.onSubmit(onFormSearchFormSubmit)}
>
<Select
className='md:ml-auto'
icon={<BsSortUpAlt />}
placeholder='Filter By'
clearable
{...searchForm.getInputProps('sort')}
onChange={(value) => {
searchForm.setValues({
filter: value ?? 'blogs',
});
}}
data={[
{ value: 'blogs', label: 'Blogs' },
{ value: 'photos', label: 'Photos' },
{ value: 'videos', label: 'Videos' },
{ value: 'audios', label: 'Audios' },
]}
/>
</form>
</div>
<div className='my-10'>
{posts.map((post) => (
<Post post={post} key={post.id} />
))}
</div>
<div className='shadow-nice p-5 bg-white flex justify-center my-10'>
<Pagination value={activePage} onChange={setPage} total={10} />
</div>
</>
) : (
<div className='shadow-nice bg-white p-4 rounded'>
<Center h={200}>
<div className='text-center text-gray-400'>
<TbTimelineEventText className='text-4xl' />
<p className='m-0'>Not Bookmarks yet</p>
</div>
</Center>
</div>
)}
</Async>
</>
);
}
export default Bookmarks;