changed onboarrding mutation to change the onboarding settings
This commit is contained in:
parent
527bc7f67e
commit
d839e235e5
2 changed files with 14 additions and 19 deletions
|
|
@ -3,7 +3,7 @@ import {
|
||||||
useMutation,
|
useMutation,
|
||||||
useQueryClient,
|
useQueryClient,
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import { ONBOARDING_OPENRAG_DOCS_FILTER_ID_KEY } from "@/lib/constants";
|
import { useUpdateOnboardingStateMutation } from "./useUpdateOnboardingStateMutation";
|
||||||
|
|
||||||
export interface OnboardingVariables {
|
export interface OnboardingVariables {
|
||||||
// Provider selection
|
// Provider selection
|
||||||
|
|
@ -36,12 +36,14 @@ export const useOnboardingMutation = (
|
||||||
options?: Omit<
|
options?: Omit<
|
||||||
UseMutationOptions<OnboardingResponse, Error, OnboardingVariables>,
|
UseMutationOptions<OnboardingResponse, Error, OnboardingVariables>,
|
||||||
"mutationFn"
|
"mutationFn"
|
||||||
>,
|
>
|
||||||
) => {
|
) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|
||||||
|
const updateOnboardingMutation = useUpdateOnboardingStateMutation();
|
||||||
|
|
||||||
async function submitOnboarding(
|
async function submitOnboarding(
|
||||||
variables: OnboardingVariables,
|
variables: OnboardingVariables
|
||||||
): Promise<OnboardingResponse> {
|
): Promise<OnboardingResponse> {
|
||||||
const response = await fetch("/api/onboarding", {
|
const response = await fetch("/api/onboarding", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
|
|
@ -62,10 +64,15 @@ export const useOnboardingMutation = (
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: submitOnboarding,
|
mutationFn: submitOnboarding,
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
// Store OpenRAG Docs filter ID if returned
|
// Save OpenRAG docs filter ID if sample data was ingested
|
||||||
if (data.openrag_docs_filter_id && typeof window !== "undefined") {
|
if (data.openrag_docs_filter_id) {
|
||||||
localStorage.setItem(
|
// Save to backend
|
||||||
ONBOARDING_OPENRAG_DOCS_FILTER_ID_KEY,
|
updateOnboardingMutation.mutateAsync({
|
||||||
|
openrag_docs_filter_id: data.openrag_docs_filter_id,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(
|
||||||
|
"Saved OpenRAG docs filter ID:",
|
||||||
data.openrag_docs_filter_id
|
data.openrag_docs_filter_id
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,8 +174,6 @@ const OnboardingCard = ({
|
||||||
// Track which tasks we've already handled to prevent infinite loops
|
// Track which tasks we've already handled to prevent infinite loops
|
||||||
const handledFailedTasksRef = useRef<Set<string>>(new Set());
|
const handledFailedTasksRef = useRef<Set<string>>(new Set());
|
||||||
|
|
||||||
const updateOnboardingMutation = useUpdateOnboardingStateMutation();
|
|
||||||
|
|
||||||
// Query tasks to track completion
|
// Query tasks to track completion
|
||||||
const { data: tasks } = useGetTasksQuery({
|
const { data: tasks } = useGetTasksQuery({
|
||||||
enabled: currentStep !== null, // Only poll when onboarding has started
|
enabled: currentStep !== null, // Only poll when onboarding has started
|
||||||
|
|
@ -308,16 +306,6 @@ const OnboardingCard = ({
|
||||||
onSuccess: (data) => {
|
onSuccess: (data) => {
|
||||||
console.log("Onboarding completed successfully", data);
|
console.log("Onboarding completed successfully", data);
|
||||||
|
|
||||||
// Save OpenRAG docs filter ID if sample data was ingested
|
|
||||||
if (data.openrag_docs_filter_id) {
|
|
||||||
// Save to backend
|
|
||||||
updateOnboardingMutation.mutateAsync({
|
|
||||||
openrag_docs_filter_id: data.openrag_docs_filter_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
console.log("Saved OpenRAG docs filter ID:", data.openrag_docs_filter_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update provider health cache to healthy since backend just validated
|
// Update provider health cache to healthy since backend just validated
|
||||||
const provider =
|
const provider =
|
||||||
(isEmbedding ? settings.embedding_provider : settings.llm_provider) ||
|
(isEmbedding ? settings.embedding_provider : settings.llm_provider) ||
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue