fix: project details table refresh

This commit is contained in:
Théo LAGACHE
2026-02-10 11:44:45 +01:00
parent a49b6d6573
commit 921a355ae0
48 changed files with 808 additions and 566 deletions
+12
View File
@@ -46,3 +46,15 @@ export const updateAgentAction = userAction
data: updatedAgent,
};
});
export const getAgentAction = userAction.schema(z.string()).action(async ({parsedInput}) => {
const agent = await db.query.agent.findFirst({
where: eq(drizzleDb.schemas.agent.id, parsedInput),
with: {
databases: true
}
});
return {
data: agent,
};
});
@@ -13,7 +13,7 @@ import {Input} from "@/components/ui/input";
import {Form} from "@/components/ui/form";
import {Button} from "@/components/ui/button";
import {useRouter} from "next/navigation";
import {useMutation} from "@tanstack/react-query";
import {useMutation, useQueryClient} from "@tanstack/react-query";
import {TooltipProvider} from "@/components/ui/tooltip";
import {AgentSchema, AgentType} from "@/features/agents/agents.schema";
import {toast} from "sonner";
@@ -27,6 +27,7 @@ export type agentFormProps = {
export const AgentForm = (props: agentFormProps) => {
const isCreate = !Boolean(props.defaultValues);
const queryClient = useQueryClient();
const form = useZodForm({
schema: AgentSchema,
@@ -51,7 +52,10 @@ export const AgentForm = (props: agentFormProps) => {
return;
}
toast.success(`Success ${isCreate ? "creating" : "updating"} agent`);
router.refresh();
if (!isCreate && props.agentId) {
queryClient.invalidateQueries({ queryKey: ["agent-data", props.agentId] });
}
if (props.onSuccess) {
props.onSuccess(data);