Scheduling infrastructure for absolutely everyone.
Fixes password prompt race condition (#4644)
Alex van Andel52959fe25780
diff --git a/apps/web/pages/v2/settings/my-account/profile.tsx b/apps/web/pages/v2/settings/my-account/profile.tsxindex 17662f3228f..a1adce67e0a 100644--- a/apps/web/pages/v2/settings/my-account/profile.tsx+++ b/apps/web/pages/v2/settings/my-account/profile.tsx@@ -1,6 +1,6 @@import crypto from "crypto";import { signOut } from "next-auth/react";-import { useRef, useState, BaseSyntheticEvent } from "react";+import { useRef, useState, BaseSyntheticEvent, useEffect } from "react";import { Controller, useForm } from "react-hook-form";import { ErrorCode } from "@calcom/lib/auth";@@ -124,15 +124,26 @@ const ProfileView = () => {deleteMeMutation.mutate({ password, totpCode });};- const formMethods = useForm({- defaultValues: {- avatar: user?.avatar || "",- username: user?.username || "",- name: user?.name || "",- email: user?.email || "",- bio: user?.bio || "",- },- });+ const formMethods = useForm<{+ avatar?: string;+ username?: string;+ name?: string;+ email?: string;+ bio?: string;+ }>();++ const { reset } = formMethods;++ useEffect(() => {+ if (user)+ reset({+ avatar: user?.avatar || "",+ username: user?.username || "",+ name: user?.name || "",+ email: user?.email || "",+ bio: user?.bio || "",+ });+ }, [reset, user]);// eslint-disable-next-line @typescript-eslint/no-non-null-assertionconst passwordRef = useRef<HTMLInputElement>(null!);