From b8304282510358276828f2682becf1aaf2d5ec27 Mon Sep 17 00:00:00 2001 From: nessi Date: Fri, 6 Feb 2026 12:51:20 +0100 Subject: [PATCH] Refactor AdminPanel: Move function definition above useEffect. This change reorders the `AdminPanel` function definition to appear before the `useEffect` hook, enhancing readability and maintaining consistent organization. No functionality is altered. --- frontend/src/components/AdminPanel.jsx | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/AdminPanel.jsx b/frontend/src/components/AdminPanel.jsx index 12ef778..f0762a4 100644 --- a/frontend/src/components/AdminPanel.jsx +++ b/frontend/src/components/AdminPanel.jsx @@ -4,17 +4,6 @@ import { styles } from "../styles/styles"; import { stylesTokens } from "../styles/theme"; import { createPortal } from "react-dom"; - -useEffect(() => { - if (!open) return; - - const prev = document.body.style.overflow; - document.body.style.overflow = "hidden"; - - return () => { - document.body.style.overflow = prev; - }; - }, [open]); export default function AdminPanel() { const [users, setUsers] = useState([]); @@ -25,6 +14,17 @@ export default function AdminPanel() { const [role, setRole] = useState("user"); const [msg, setMsg] = useState(""); + useEffect(() => { + if (!open) return; + + const prev = document.body.style.overflow; + document.body.style.overflow = "hidden"; + + return () => { + document.body.style.overflow = prev; + }; + }, [open]); + const loadUsers = async () => { const u = await api("/admin/users"); setUsers(u);