Skip to content

Commit

Permalink
fix: infinite loop in onboarding (#1604)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattinannt committed Nov 10, 2023
1 parent 84ce0c2 commit c2675a9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 17 deletions.
6 changes: 2 additions & 4 deletions apps/web/app/(app)/onboarding/components/Objective.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 1 addition & 6 deletions apps/web/app/(app)/onboarding/components/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 4 additions & 7 deletions apps/web/app/(app)/onboarding/components/Role.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -13,15 +12,14 @@ type RoleProps = {
next: () => void;
skip: () => void;
setFormbricksResponseId: (id: string) => void;
profile: TProfile;
};

type RoleChoice = {
label: string;
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);

Expand All @@ -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);
Expand Down

2 comments on commit c2675a9

@vercel
Copy link

@vercel vercel bot commented on c2675a9 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formbricks-com – ./apps/formbricks-com

www.formbricks.com
formbricks-com.vercel.app
formbricks-com-formbricks.vercel.app
formbricks-com-git-main-formbricks.vercel.app
formbricks.com

@vercel
Copy link

@vercel vercel bot commented on c2675a9 Nov 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.