diff --git a/app/(customer)/dashboard/(admin)/agents/[agentId]/page.tsx b/app/(customer)/dashboard/(admin)/agents/[agentId]/page.tsx index b1080be8..4959e901 100644 --- a/app/(customer)/dashboard/(admin)/agents/[agentId]/page.tsx +++ b/app/(customer)/dashboard/(admin)/agents/[agentId]/page.tsx @@ -1,8 +1,5 @@ -import Link from "next/link"; -import {GearIcon} from "@radix-ui/react-icons"; import {PageParams} from "@/types/next"; -import {Page, PageActions, PageContent, PageDescription, PageTitle} from "@/features/layout/page"; -import {buttonVariants} from "@/components/ui/button"; +import {Page, PageContent, PageDescription, PageTitle} from "@/features/layout/page"; import {db} from "@/db"; import * as drizzleDb from "@/db"; import {eq} from "drizzle-orm"; @@ -39,18 +36,14 @@ export default async function RoutePage(props: PageParams<{ agentId: string }>)
{capitalizeFirstLetter(agent.name)}
-
-
- -
- -
-
-
-
- -
+
+
+
+
+ +
+
diff --git a/app/(customer)/dashboard/(admin)/agents/page.tsx b/app/(customer)/dashboard/(admin)/agents/page.tsx index 21d81a66..cffe5c55 100644 --- a/app/(customer)/dashboard/(admin)/agents/page.tsx +++ b/app/(customer)/dashboard/(admin)/agents/page.tsx @@ -1,13 +1,11 @@ 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"; 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 {desc, eq, not} from "drizzle-orm"; -import {EmptyStatePlaceholder} from "@/components/wrappers/common/empty-state-placeholder"; import {Metadata} from "next"; import {AgentDialog} from "@/features/agents/components/agent.dialog"; @@ -25,7 +23,6 @@ export default async function RoutePage(props: PageParams<{}>) { orderBy: (fields) => desc(fields.lastContact), }); - if (!agents) { notFound(); } @@ -36,9 +33,7 @@ export default async function RoutePage(props: PageParams<{}>) { Agents {agents.length > 0 && ( - - - + )} @@ -46,11 +41,7 @@ export default async function RoutePage(props: PageParams<{}>) { {agents.length > 0 ? ( ) : ( - - - + )} diff --git a/src/components/wrappers/common/empty-state-placeholder.tsx b/src/components/wrappers/common/empty-state-placeholder.tsx index 3339053c..f9831ebf 100644 --- a/src/components/wrappers/common/empty-state-placeholder.tsx +++ b/src/components/wrappers/common/empty-state-placeholder.tsx @@ -1,14 +1,14 @@ import Link from "next/link"; import {cn} from "@/lib/utils"; import {Plus} from "lucide-react"; -import {forwardRef} from "react"; +import {forwardRef, HTMLAttributes} from "react"; type EmptyStatePlaceholderProps = { url?: string; onClick?: () => void; text: string; className?: string; -} & React.HTMLAttributes; +} & HTMLAttributes; export const EmptyStatePlaceholder = forwardRef(({ url, diff --git a/src/features/agents/components/agent.dialog.tsx b/src/features/agents/components/agent.dialog.tsx index 67d095d6..8358df8f 100644 --- a/src/features/agents/components/agent.dialog.tsx +++ b/src/features/agents/components/agent.dialog.tsx @@ -8,35 +8,55 @@ import { DialogTrigger, } from "@/components/ui/dialog"; import {AgentForm} from "@/features/agents/components/agent.form"; -import {useState} from "react"; -import {Button} from "@/components/ui/button"; +import {Button, buttonVariants} from "@/components/ui/button"; import {Plus} from "lucide-react"; import {AgentType} from "@/features/agents/agents.schema"; +import {GearIcon} from "@radix-ui/react-icons"; +import {EmptyStatePlaceholder} from "@/components/wrappers/common/empty-state-placeholder"; +import {useState} from "react"; type AgentDialogProps = { - children?: React.ReactNode; agent?: AgentType & { id: string }; + typeTrigger: "edit" | "empty" | "create"; }; -export const AgentDialog = ({children, agent}: AgentDialogProps) => { + +export const AgentDialog = ({agent, typeTrigger}: AgentDialogProps) => { const [open, setOpen] = useState(false); const isEdit = !!agent; + const getTrigger = () => { + switch (typeTrigger) { + case "edit": + return ( +
+ +
+ ); + case "empty": + return ; + case "create": + return ; + default: + return ; + } + }; + return ( - - {children ? children : } - - + {getTrigger()} + e.preventDefault()} + > {isEdit ? `Edit ${agent.name}` : "Create new agent"} - setOpen(false)} + setOpen(false)} defaultValues={agent} agentId={agent?.id} /> ); -}; \ No newline at end of file +};