mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
* feat: org agent management * feat: org agent management * fix: adding migrations for legacy and refactoring. * fix: refactoring * fix: delete agent * fix: refactoring --------- Co-authored-by: charles-gauthereau <charles.gauthereau@soluce-technologies.com>
49 lines
1.6 KiB
TypeScript
49 lines
1.6 KiB
TypeScript
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 {Page, PageActions, PageContent, PageHeader, PageTitle} from "@/features/layout/page";
|
|
import {notFound} from "next/navigation";
|
|
import {db} from "@/db";
|
|
import * as drizzleDb from "@/db";
|
|
import {and, desc, eq, isNull, not} from "drizzle-orm";
|
|
import {Metadata} from "next";
|
|
import {AgentDialog} from "@/features/agents/components/agent.dialog";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Agents",
|
|
};
|
|
|
|
export default async function RoutePage(props: PageParams<{}>) {
|
|
|
|
const agents = await db.query.agent.findMany({
|
|
where: and(not(eq(drizzleDb.schemas.agent.isArchived, true)),isNull(drizzleDb.schemas.agent.organizationId)),
|
|
with: {
|
|
databases: true
|
|
},
|
|
orderBy: (fields) => desc(fields.lastContact),
|
|
});
|
|
|
|
if (!agents) {
|
|
notFound();
|
|
}
|
|
|
|
return (
|
|
<Page>
|
|
<PageHeader>
|
|
<PageTitle>Agents</PageTitle>
|
|
{agents.length > 0 && (
|
|
<PageActions>
|
|
<AgentDialog typeTrigger={"create"} />
|
|
</PageActions>
|
|
)}
|
|
</PageHeader>
|
|
<PageContent>
|
|
{agents.length > 0 ? (
|
|
<CardsWithPagination data={agents} cardItem={AgentCard} cardsPerPage={4} numberOfColumns={1}/>
|
|
) : (
|
|
<AgentDialog typeTrigger="empty"/>
|
|
)}
|
|
</PageContent>
|
|
</Page>
|
|
);
|
|
} |