MCPcopy
hub / github.com/Peppermint-Lab/peppermint / NewLayout

Function NewLayout

apps/client/layouts/newLayout.tsx:31–532  ·  view source on GitHub ↗
({ children }: any)

Source from the content-addressed store, hash-verified

29import { useUser } from "../store/session";
30
31export default function NewLayout({ children }: any) {
32 const location = useRouter();
33
34 const { loading, user, fetchUserProfile } = useUser();
35 const locale = user ? user.language : "en";
36
37 const [keypressdown, setKeyPressDown] = useState(false);
38
39 const { t, lang } = useTranslation("peppermint");
40
41 const [sidebarOpen, setSidebarOpen] = useState(false);
42
43 if (!user) {
44 location.push("/auth/login");
45 }
46
47 if (location.pathname.includes("/admin") && user.isAdmin === false) {
48 location.push("/");
49 alert("You do not have the correct perms for that action.");
50 }
51
52 if (user && user.external_user) {
53 location.push("/portal");
54 }
55
56 const navigation = [
57 {
58 name: t("sl_dashboard"),
59 href: `/${locale}/`,
60 icon: Building,
61 current: location.pathname === "/" ? true : false,
62 initial: "h",
63 },
64 {
65 name: "Documents",
66 href: `/${locale}/documents`,
67 icon: FileText,
68 current: location.pathname === "/documents" ? true : false,
69 initial: "d",
70 internal: true,
71 },
72 ];
73
74 function handleKeyPress(event: any) {
75 const pathname = location.pathname;
76
77 // Check for Ctrl or Meta key to bypass the shortcut handler
78 if (event.ctrlKey || event.metaKey) {
79 return; // Don't override browser shortcuts
80 }
81
82 if (
83 document.activeElement!.tagName !== "INPUT" &&
84 document.activeElement!.tagName !== "TEXTAREA" &&
85 !document.activeElement!.className.includes("ProseMirror") &&
86 !pathname.includes("/new")
87 ) {
88 switch (event.key) {

Callers

nothing calls this directly

Calls 2

useUserFunction · 0.90
classNamesFunction · 0.90

Tested by

no test coverage detected