mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 17:21:41 +10:00
fix user loading on refresh
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
import { Fragment, useEffect } from "react";
|
import { Fragment, useEffect, useState } from "react";
|
||||||
import { Disclosure, Menu, Transition } from "@headlessui/react";
|
import { Disclosure, Menu, Transition } from "@headlessui/react";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
@ -18,13 +18,6 @@ import {
|
|||||||
} from "@heroicons/react/24/outline";
|
} from "@heroicons/react/24/outline";
|
||||||
import Logo from "./logo";
|
import Logo from "./logo";
|
||||||
|
|
||||||
let user: {
|
|
||||||
id?: number | undefined;
|
|
||||||
name?: string | null;
|
|
||||||
email?: string | null;
|
|
||||||
image?: string | null;
|
|
||||||
};
|
|
||||||
|
|
||||||
const navigation = [
|
const navigation = [
|
||||||
{
|
{
|
||||||
name: "Dashboard",
|
name: "Dashboard",
|
||||||
@ -77,12 +70,20 @@ function classNames(...classes: any) {
|
|||||||
return classes.filter(Boolean).join(" ");
|
return classes.filter(Boolean).join(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type UserType = {
|
||||||
|
id?: number | undefined;
|
||||||
|
name?: string | null;
|
||||||
|
email?: string | null;
|
||||||
|
image?: string | null;
|
||||||
|
};
|
||||||
|
|
||||||
export default function TopNavigation() {
|
export default function TopNavigation() {
|
||||||
|
const [user, setUser] = useState<UserType>();
|
||||||
const session = useSession();
|
const session = useSession();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
user = { ...session.data?.user };
|
setUser(session.data?.user);
|
||||||
});
|
}, [session]);
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
navigation.forEach((element) => {
|
navigation.forEach((element) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user