Files
portabase/app/(customer)/dashboard/(admin)/agents/page.tsx
T

58 lines
1.9 KiB
TypeScript
Raw Normal View History

2025-11-04 08:48:46 +01:00
import {PageParams} from "@/types/next";
import {AgentCard} from "@/components/wrappers/dashboard/agent/agent-card/agent-card";
import {CardsWithPagination} from "@/components/wrappers/common/cards-with-pagination";
import {Button} from "@/components/ui/button";
2025-05-16 15:54:17 +02:00
import Link from "next/link";
2025-11-04 08:48:46 +01:00
import {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
import {notFound} from "next/navigation";
import {db} from "@/db";
2025-07-27 21:26:31 +02:00
import * as drizzleDb from "@/db";
2026-01-04 21:24:06 +01:00
import {desc, eq, not} from "drizzle-orm";
2025-08-02 08:48:45 +02:00
import {EmptyStatePlaceholder} from "@/components/wrappers/common/empty-state-placeholder";
2025-11-04 08:48:46 +01:00
import {Metadata} from "next";
export const metadata: Metadata = {
title: "Agents",
};
export default async function RoutePage(props: PageParams<{}>) {
2025-07-27 21:26:31 +02:00
const agents = await db.query.agent.findMany({
2025-12-21 11:25:33 +01:00
where: not(eq(drizzleDb.schemas.agent.isArchived, true)),
with: {
databases: true
2026-01-04 21:24:06 +01:00
},
orderBy: (fields) => desc(fields.createdAt),
2025-07-27 21:26:31 +02:00
});
2025-05-16 15:54:17 +02:00
if (!agents) {
notFound();
}
2025-02-21 08:43:01 +01:00
return (
2024-11-10 23:12:38 +01:00
<Page>
<PageHeader>
2025-05-16 15:54:17 +02:00
<PageTitle>Agents</PageTitle>
{agents.length > 0 && (
<PageActions>
<Link href={"/dashboard/agents/new"}>
<Button>+ Create Agent</Button>
</Link>
</PageActions>
)}
2024-11-10 23:12:38 +01:00
</PageHeader>
2025-07-26 22:23:00 +02:00
<PageContent>
2025-05-16 15:54:17 +02:00
{agents.length > 0 ? (
2025-11-04 08:48:46 +01:00
<CardsWithPagination data={agents} cardItem={AgentCard} cardsPerPage={4} numberOfColumns={1}/>
2025-05-16 15:54:17 +02:00
) : (
2025-08-02 08:48:45 +02:00
<EmptyStatePlaceholder
url={"/dashboard/agents/new"}
text={"Create new Agent"}
/>
2025-05-16 15:54:17 +02:00
)}
2024-11-10 23:12:38 +01:00
</PageContent>
</Page>
2025-05-16 15:54:17 +02:00
);
}