saving ux minus refactor

This commit is contained in:
Timur Ercan
2023-01-25 13:22:47 +01:00
parent 8f4b733eda
commit 0f9df1afc9
4 changed files with 104 additions and 22 deletions

View File

@@ -78,14 +78,21 @@ type UserType = {
};
export default function TopNavigation() {
const [user, setUser] = useState<UserType>();
const router = useRouter();
const session = useSession();
const [user, setUser] = useState({
email: "",
name: "",
});
useEffect(() => {
setUser(session.data?.user);
}, [session]);
fetch("/api/users/me").then((res) => {
res.json().then((j) => {
setUser(j);
});
});
}, [session, user]);
const router = useRouter();
navigation.forEach((element) => {
element.current = router.route.endsWith("/" + element.href.split("/")[1]);
});