Skip to content

Commit

Permalink
Add My Agents List Page
Browse files Browse the repository at this point in the history
The new AgentListPage component has been created as part of the "agents/mine" directory. This component, which incorporates AgentListMine, uses the getCurrentUser function and redirects to the sign-in page if there is no user data, improving security by enforcing authenticated access.
  • Loading branch information
mikepsinn committed Jul 24, 2024
1 parent e6384ea commit ab6a72d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 30 deletions.
28 changes: 0 additions & 28 deletions app/agents/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Metadata, Viewport } from "next"

import { ChatHistory } from "@/components/ChatHistory"
import SidebarDesktop from "@/components/SidebarDesktop"
import SidebarMobile from "@/components/SidebarMobile"
Expand All @@ -10,32 +8,6 @@ interface ChatLayoutProps {
children: React.ReactNode
}

const title = "Talk to Wishonia"
const description =
"Wishonia is a magical kingdom where resources are allocated to maximize universal wish fulfillment. Talk to Wishonia's AI to learn more."
export const metadata: Metadata = {
metadataBase: new URL("https://wishonia.love/chat"),
title,
description,
openGraph: {
title,
description,
},
twitter: {
title,
description,
card: "summary_large_image",
creator: "@thinkbynumbers",
},
}

export const viewport: Viewport = {
width: "device-width",
initialScale: 1,
minimumScale: 1,
maximumScale: 1,
}

export default async function ChatLayout({ children }: ChatLayoutProps) {
return (
<Providers>
Expand Down
19 changes: 19 additions & 0 deletions app/agents/mine/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react"
import { redirect } from "next/navigation"

import { authOptions } from "@/lib/auth"
import { getCurrentUser } from "@/lib/session"
import AgentListMine from "@/components/agents/agent-list-mine"
import { Shell } from "@/components/layout/shell"

export default async function AgentListPage() {
const user = await getCurrentUser()
if (!user) {
redirect(authOptions?.pages?.signIn || "/signin")
}
return (
<Shell className="size-full">
<AgentListMine></AgentListMine>
</Shell>
)
}
4 changes: 2 additions & 2 deletions app/agents/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { redirect } from "next/navigation"

import { authOptions } from "@/lib/auth"
import { getCurrentUser } from "@/lib/session"
import AgentList from "@/components/agents/agent-list"
import { Shell } from "@/components/layout/shell"
import AgentListPublished from "@/components/agents/agent-list-published";

export default async function AgentListPage() {
const user = await getCurrentUser()
Expand All @@ -13,7 +13,7 @@ export default async function AgentListPage() {
}
return (
<Shell className="size-full">
<AgentList></AgentList>
<AgentListPublished></AgentListPublished>
</Shell>
)
}

0 comments on commit ab6a72d

Please sign in to comment.