Added required mutations on frontend

This commit is contained in:
Lucas Oliveira 2025-12-23 13:21:46 -03:00
parent 9b012f40e9
commit f7f1553f1d
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,44 @@
import { useMutation, useQueryClient } from "@tanstack/react-query";
interface UpdateOnboardingStateVariables {
current_step?: number;
assistant_message?: {
role: string;
content: string;
timestamp: string;
} | null;
selected_nudge?: string | null;
card_steps?: Record<string, unknown> | null;
upload_steps?: Record<string, unknown> | null;
openrag_docs_filter_id?: string | null;
user_doc_filter_id?: string | null;
}
export const useUpdateOnboardingStateMutation = () => {
const queryClient = useQueryClient();
return useMutation({
mutationFn: async (variables: UpdateOnboardingStateVariables) => {
const response = await fetch("/api/onboarding/state", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(variables),
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || "Failed to update onboarding state");
}
return response.json();
},
onSuccess: () => {
// Invalidate settings query to refetch updated onboarding state
queryClient.invalidateQueries({ queryKey: ["settings"] });
},
});
};
// Made with Bob

View file

@ -41,12 +41,27 @@ export interface ProviderSettings {
};
}
export interface OnboardingState {
current_step?: number;
assistant_message?: {
role: string;
content: string;
timestamp: string;
} | null;
selected_nudge?: string | null;
card_steps?: Record<string, unknown> | null;
upload_steps?: Record<string, unknown> | null;
openrag_docs_filter_id?: string | null;
user_doc_filter_id?: string | null;
}
export interface Settings {
langflow_url?: string;
flow_id?: string;
ingest_flow_id?: string;
langflow_public_url?: string;
edited?: boolean;
onboarding?: OnboardingState;
providers?: ProviderSettings;
knowledge?: KnowledgeSettings;
agent?: AgentSettings;