-
Notifications
You must be signed in to change notification settings - Fork 0
/
HomePage.tsx
51 lines (40 loc) · 1.41 KB
/
HomePage.tsx
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
import { Divider } from "antd";
import FileExplorer from "./components/FileExplorer";
import { Typography } from "antd";
import { getPagesByUserId } from "../../store/API/Page";
import { useDispatch, useSelector } from "react-redux";
import { useEffect, useState } from "react";
import "./index.css";
import { RootState } from "../../store/store";
import { IUserState } from "../../store/slices/authSlice";
import EmptyData from "../../global-components/EmptyData";
import RecentsFiles from "./components/RecentsFiles";
import UserCard from "./components/UserCard";
const { Title } = Typography;
const HomePage = () => {
const user: IUserState | undefined = useSelector(
(state: RootState) => state.auth.user
);
const treeData = useSelector((state: RootState) => state.Tree);
const [files, setFiles] = useState<any>([]);
//const navigate = useNavigate();
const dispatch = useDispatch();
useEffect(() => {
(async () => {
if (!user) return;
const pages = await getPagesByUserId(user.userId);
setFiles(pages);
})();
}, [user, treeData, dispatch]);
return (
<>
{user && <UserCard user={user} />}
<RecentsFiles files={files} />
{files.length === 0 && <EmptyData message={"No data available"} />}
<Divider />
<Title level={3}>Files Explorer</Title>
<FileExplorer treeData={treeData} userId={user?.userId} />
</>
);
};
export default HomePage;