mirror of
https://github.com/cssgunc/compass.git
synced 2025-04-09 14:00:15 -04:00
Fix indefinite loading spinner when navigating to same page
This commit is contained in:
parent
fdbf4ffa40
commit
63fa7db352
|
@ -15,7 +15,6 @@ export default function RootLayout({
|
|||
const [isSidebarOpen, setIsSidebarOpen] = useState(true);
|
||||
const [user, setUser] = useState<User>();
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
async function getUser() {
|
||||
|
@ -36,7 +35,6 @@ export default function RootLayout({
|
|||
);
|
||||
|
||||
setUser(await userData.json());
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
getUser();
|
||||
|
@ -52,7 +50,6 @@ export default function RootLayout({
|
|||
setIsSidebarOpen={setIsSidebarOpen}
|
||||
isSidebarOpen={isSidebarOpen}
|
||||
isAdmin={user.role === Role.ADMIN}
|
||||
loading={loading}
|
||||
/>
|
||||
<div
|
||||
className={`flex-1 transition duration-300 ease-in-out ${
|
||||
|
|
|
@ -9,7 +9,6 @@ import {
|
|||
LockClosedIcon,
|
||||
} from "@heroicons/react/24/solid";
|
||||
import { SidebarItem } from "./SidebarItem";
|
||||
import styles from "./LoadingIcon.module.css";
|
||||
import { UserProfile } from "../resource/UserProfile";
|
||||
import LoadingIcon from "./LoadingIcon";
|
||||
|
||||
|
@ -19,7 +18,6 @@ interface SidebarProps {
|
|||
name: string;
|
||||
email: string;
|
||||
isAdmin: boolean;
|
||||
loading: boolean;
|
||||
}
|
||||
|
||||
const Sidebar: React.FC<SidebarProps> = ({
|
||||
|
@ -28,7 +26,6 @@ const Sidebar: React.FC<SidebarProps> = ({
|
|||
name,
|
||||
email,
|
||||
isAdmin: admin,
|
||||
loading,
|
||||
}) => {
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
return (
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import Link from "next/link";
|
||||
import { usePathname } from "next/navigation";
|
||||
|
||||
interface SidebarItemProps {
|
||||
icon: React.ReactElement;
|
||||
|
@ -15,9 +16,13 @@ export const SidebarItem: React.FC<SidebarItemProps> = ({
|
|||
redirect,
|
||||
onClick,
|
||||
}) => {
|
||||
const pathname = usePathname();
|
||||
|
||||
return (
|
||||
<Link
|
||||
onClick={() => onClick(true)}
|
||||
onClick={() =>
|
||||
pathname.startsWith(redirect) ? onClick(false) : onClick(true)
|
||||
}
|
||||
href={redirect}
|
||||
className={
|
||||
active
|
||||
|
|
Loading…
Reference in New Issue
Block a user