diff --git a/app/(main)/(routes)/servers/[serverId]/page.tsx b/app/(main)/(routes)/servers/[serverId]/page.tsx new file mode 100644 index 0000000..6f2c090 --- /dev/null +++ b/app/(main)/(routes)/servers/[serverId]/page.tsx @@ -0,0 +1,8 @@ +const ServerIdPage = () => { + return ( +
+ Server ID Page +
+ ); +} +export default ServerIdPage; \ No newline at end of file diff --git a/app/(main)/layout.tsx b/app/(main)/layout.tsx new file mode 100644 index 0000000..f0a5f77 --- /dev/null +++ b/app/(main)/layout.tsx @@ -0,0 +1,20 @@ +import { NavigationSidebar } from "@/components/navigation/navigation-sidebar"; + +const MainLayout = async ({ + children +}: { + children: React.ReactNode; +}) => { + return ( +
+
+ +
+
+ {children} +
+
+ ); +} + +export default MainLayout; \ No newline at end of file diff --git a/components/navigation/navigation-action.tsx b/components/navigation/navigation-action.tsx new file mode 100644 index 0000000..49075f8 --- /dev/null +++ b/components/navigation/navigation-action.tsx @@ -0,0 +1,28 @@ +"use client" + +import { Plus } from "lucide-react" + +import { ActionTooltip } from "@/components/action-tooltip" + +export const NavigationAction = () => { + return ( +
+ + + +
+ ) +} \ No newline at end of file diff --git a/components/navigation/navigation-item.tsx b/components/navigation/navigation-item.tsx new file mode 100644 index 0000000..50e2965 --- /dev/null +++ b/components/navigation/navigation-item.tsx @@ -0,0 +1,54 @@ +"use client" + +import Image from "next/image" +import { useParams, useRouter } from "next/navigation" + +import { cn } from "@/lib/utils" +import { ActionTooltip } from "@/components/action-tooltip" + +interface NavigationItemProps { + id: string; + imageUrl: string; + name: string; +}; + +export const NavigationItem = ({ + id, + imageUrl, + name +}: NavigationItemProps) => { + const params = useParams(); + const router = useRouter(); + + const onClick = () => { + router.push(`/servers/${id}`); + } + return ( + + + + ) +} diff --git a/components/navigation/navigation-sidebar.tsx b/components/navigation/navigation-sidebar.tsx new file mode 100644 index 0000000..f2bee6d --- /dev/null +++ b/components/navigation/navigation-sidebar.tsx @@ -0,0 +1,62 @@ +import { redirect } from "next/navigation"; + +import { ModeToggle } from "@/components/mode-toggle"; +import { ScrollArea } from "@/components/ui/scroll-area"; +import { Separator } from "@/components/ui/separator"; +import { currentProfile } from "@/lib/current-profile"; +import { db } from "@/lib/db"; + +import { NavigationAction } from "./navigation-action"; +import { NavigationItem } from "./navigation-item"; +import { UserButton } from "@clerk/nextjs"; + + +export const NavigationSidebar = async () => { + const profile = await currentProfile(); + + if (!profile) { + return redirect("/"); + } + + const servers = await db.server.findMany({ + where: { + members: { + some: { + profileId: profile.id, + }, + }, + }, + }) + + return ( +
+ + + + {servers.map((server) => ( +
+ +
+ ))} +
+
+ + +
+
+ ) +} \ No newline at end of file