mirror of
https://github.com/Portabase/portabase.git
synced 2026-07-14 11:16:13 +02:00
fix: project details table refresh
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user