mirror of
https://github.com/formbricks/formbricks.git
synced 2026-04-19 02:10:33 -05:00
fix: infinite loop in onboarding (#1604)
This commit is contained in:
@@ -41,12 +41,10 @@ const Objective: React.FC<ObjectiveProps> = ({ next, skip, formbricksResponseId,
|
||||
if (selectedObjective) {
|
||||
try {
|
||||
setIsProfileUpdating(true);
|
||||
const updatedProfile = {
|
||||
...profile,
|
||||
await updateProfileAction({
|
||||
objective: selectedObjective.id,
|
||||
name: profile.name ?? undefined,
|
||||
};
|
||||
await updateProfileAction(updatedProfile);
|
||||
});
|
||||
setIsProfileUpdating(false);
|
||||
} catch (e) {
|
||||
setIsProfileUpdating(false);
|
||||
|
||||
@@ -88,12 +88,7 @@ export default function Onboarding({ session, environmentId, profile, product }:
|
||||
<Greeting next={next} skip={doLater} name={profile.name ? profile.name : ""} session={session} />
|
||||
)}
|
||||
{currentStep === 2 && (
|
||||
<Role
|
||||
next={next}
|
||||
skip={skipStep}
|
||||
setFormbricksResponseId={setFormbricksResponseId}
|
||||
profile={profile}
|
||||
/>
|
||||
<Role next={next} skip={skipStep} setFormbricksResponseId={setFormbricksResponseId} />
|
||||
)}
|
||||
{currentStep === 3 && (
|
||||
<Objective
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
"use client";
|
||||
|
||||
import { cn } from "@formbricks/lib/cn";
|
||||
import { updateProfileAction } from "@/app/(app)/onboarding/actions";
|
||||
import { env } from "@/env.mjs";
|
||||
import { createResponse, formbricksEnabled } from "@/app/lib/formbricks";
|
||||
import { TProfile } from "@formbricks/types/profile";
|
||||
import { env } from "@/env.mjs";
|
||||
import { cn } from "@formbricks/lib/cn";
|
||||
import { Button } from "@formbricks/ui/Button";
|
||||
import { useState } from "react";
|
||||
import { toast } from "react-hot-toast";
|
||||
@@ -13,7 +12,6 @@ type RoleProps = {
|
||||
next: () => void;
|
||||
skip: () => void;
|
||||
setFormbricksResponseId: (id: string) => void;
|
||||
profile: TProfile;
|
||||
};
|
||||
|
||||
type RoleChoice = {
|
||||
@@ -21,7 +19,7 @@ type RoleChoice = {
|
||||
id: "project_manager" | "engineer" | "founder" | "marketing_specialist" | "other";
|
||||
};
|
||||
|
||||
const Role: React.FC<RoleProps> = ({ next, skip, setFormbricksResponseId, profile }) => {
|
||||
const Role: React.FC<RoleProps> = ({ next, skip, setFormbricksResponseId }) => {
|
||||
const [selectedChoice, setSelectedChoice] = useState<string | null>(null);
|
||||
const [isUpdating, setIsUpdating] = useState(false);
|
||||
|
||||
@@ -39,8 +37,7 @@ const Role: React.FC<RoleProps> = ({ next, skip, setFormbricksResponseId, profil
|
||||
if (selectedRole) {
|
||||
try {
|
||||
setIsUpdating(true);
|
||||
const updatedProfile = { ...profile, role: selectedRole.id };
|
||||
await updateProfileAction(updatedProfile);
|
||||
await updateProfileAction({ role: selectedRole.id });
|
||||
setIsUpdating(false);
|
||||
} catch (e) {
|
||||
setIsUpdating(false);
|
||||
|
||||
Reference in New Issue
Block a user