From 408f42daad4c1bf1abd05b35128846a65cbe28ee Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Sun, 13 Oct 2024 22:49:14 -0400 Subject: [PATCH] fix imports --- src/app/[orgId]/components/Header.tsx | 87 +++++++++++++++++++ .../components/TopbarNav.tsx | 6 +- src/app/[orgId]/layout.tsx | 37 +++++--- src/app/[orgId]/sites/[siteId]/page.tsx | 46 +++++----- src/app/configuration/components/Header.tsx | 80 ----------------- 5 files changed, 143 insertions(+), 113 deletions(-) create mode 100644 src/app/[orgId]/components/Header.tsx rename src/app/{configuration => [orgId]}/components/TopbarNav.tsx (90%) delete mode 100644 src/app/configuration/components/Header.tsx diff --git a/src/app/[orgId]/components/Header.tsx b/src/app/[orgId]/components/Header.tsx new file mode 100644 index 00000000..9ab5b5b5 --- /dev/null +++ b/src/app/[orgId]/components/Header.tsx @@ -0,0 +1,87 @@ +"use client"; + +import { Avatar, AvatarFallback } from "@app/components/ui/avatar"; +import { Badge } from "@app/components/ui/badge"; +import { Button } from "@app/components/ui/button"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuGroup, + DropdownMenuItem, + DropdownMenuLabel, + DropdownMenuSeparator, + DropdownMenuShortcut, + DropdownMenuTrigger, +} from "@app/components/ui/dropdown-menu"; +import Link from "next/link"; + +type HeaderProps = { + name?: string; + email: string; + orgName: string; +}; + +export default function Header({ email, orgName, name }: HeaderProps) { + function getInitials() { + if (name) { + const [firstName, lastName] = name.split(" "); + return `${firstName[0]}${lastName[0]}`; + } + return email.substring(0, 2).toUpperCase(); + } + + return ( + <> +
+ + {orgName} + + +
+
+ + {name || email} + + + + + + + +
+ {name && ( +

+ {name} +

+ )} +

+ {email} +

+
+
+ + + Profile + Log out + +
+
+
+
+
+ + ); +} diff --git a/src/app/configuration/components/TopbarNav.tsx b/src/app/[orgId]/components/TopbarNav.tsx similarity index 90% rename from src/app/configuration/components/TopbarNav.tsx rename to src/app/[orgId]/components/TopbarNav.tsx index 2ba25df5..851882ec 100644 --- a/src/app/configuration/components/TopbarNav.tsx +++ b/src/app/[orgId]/components/TopbarNav.tsx @@ -12,12 +12,14 @@ interface TopbarNavProps extends React.HTMLAttributes { icon: React.ReactNode; }[]; disabled?: boolean; + orgId: string; } export function TopbarNav({ className, items, disabled = false, + orgId, ...props }: TopbarNavProps) { const pathname = usePathname(); @@ -34,10 +36,10 @@ export function TopbarNav({ {items.map((item) => ( , }, { title: "Resources", - href: "/configuration/resources", + href: "/{orgId}/resources", icon: , }, + { + title: "Users", + href: "/{orgId}/users", + icon: , + }, + { + title: "General", + href: "/{orgId}/general", + icon: , + }, ]; interface ConfigurationLaytoutProps { children: React.ReactNode; - params: { siteId: string }; + params: { orgId: string }; } export default async function ConfigurationLaytout({ children, params, }: ConfigurationLaytoutProps) { + const user = await verifySession(); + + if (!user) { + redirect("/auth/login"); + } + return ( <> -
+
- +
-
{children}
+
{children}
); } diff --git a/src/app/[orgId]/sites/[siteId]/page.tsx b/src/app/[orgId]/sites/[siteId]/page.tsx index 7fb6fedf..81d672cc 100644 --- a/src/app/[orgId]/sites/[siteId]/page.tsx +++ b/src/app/[orgId]/sites/[siteId]/page.tsx @@ -1,26 +1,30 @@ -import React from 'react'; +import React from "react"; import { Separator } from "@/components/ui/separator"; import { ProfileForm } from "@app/components/profile-form"; import { CreateSiteForm } from "./components/create-site"; -export default function SettingsProfilePage({ params }: { params: { siteId: string } }) { - const isCreateForm = params.siteId === "create"; +export default function SettingsProfilePage({ + params, +}: { + params: { siteId: string }; +}) { + const isCreateForm = params.siteId === "create"; - return ( -
-
-

- {isCreateForm ? "Create Site" : "Profile"} -

-

- {isCreateForm - ? "Create a new site for your profile." - : "This is how others will see you on the site."} -

-
- - - {isCreateForm ? : } -
- ); -} \ No newline at end of file + return ( +
+
+

+ {isCreateForm ? "Create Site" : "Profile"} +

+

+ {isCreateForm + ? "Create a new site for your profile." + : "This is how others will see you on the site."} +

+
+ + + {isCreateForm ? : } +
+ ); +} diff --git a/src/app/configuration/components/Header.tsx b/src/app/configuration/components/Header.tsx deleted file mode 100644 index 5075a5b7..00000000 --- a/src/app/configuration/components/Header.tsx +++ /dev/null @@ -1,80 +0,0 @@ -"use client"; - -import { Avatar, AvatarFallback } from "@app/components/ui/avatar"; -import { Badge } from "@app/components/ui/badge"; -import { Button } from "@app/components/ui/button"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuGroup, - DropdownMenuItem, - DropdownMenuLabel, - DropdownMenuSeparator, - DropdownMenuShortcut, - DropdownMenuTrigger, -} from "@app/components/ui/dropdown-menu"; - -type HeaderProps = { - name?: string; - email: string; - orgName: string; -}; - -export default function Header({ email, orgName, name }: HeaderProps) { - function getInitials() { - if (name) { - const [firstName, lastName] = name.split(" "); - return `${firstName[0]}${lastName[0]}`; - } - return email.substring(0, 2).toUpperCase(); - } - - return ( - <> -
- {orgName} - -
- {name || email} - - - - - - -
- {name && ( -

- {name} -

- )} -

- {email} -

-
-
- - - Profile - Log out - -
-
-
-
- - ); -}