-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.tsx
57 lines (52 loc) · 1.94 KB
/
layout.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
52
53
54
55
56
57
import {useParams, useSearchParams} from "react-router-dom";
import {UserApi} from "@/api/UserApi.tsx";
import {useEffect, useState} from "react";
import {UserDashBored} from "@/types.ts";
import "./module.css"
import {UserHeader} from "@/app/user/User.Header.tsx";
import UserActive from "@/app/user/User.Active.tsx";
import UserRepository from "@/app/user/User.Repository.tsx";
import {UserSetting} from "@/app/user/User.Setting.tsx";
const LayoutUser = () => {
const {username} = useParams() as { username: string }
const [Query] = useSearchParams();
const [Tab, setTab] = useState("active");
const user = new UserApi();
const [dashbored, setDashbored] = useState<UserDashBored>()
const [Load, setLoad] = useState(false)
useEffect(() => {
user.DashBoredData(username)
.then(res => {
const data: UserDashBored = JSON.parse(res.data).data
setDashbored(data);
const page = Query.get("tab");
if (page) {
setTab(page)
}
setLoad(true)
})
}, [])
return (
<>
{
(Load && dashbored) && (
<div className="user">
<UserHeader setTab={setTab} user={dashbored}/>
<div className="user-body">
{
(Tab === "active" || Tab === "" || Tab === undefined) && <UserActive props={dashbored}/>
}
{
Tab === "reposiotry" && <UserRepository props={dashbored}/>
}
{
Tab === "setting" && <UserSetting props={dashbored}/>
}
</div>
</div>
)
}
</>
)
}
export default LayoutUser