Scheduling infrastructure for absolutely everyone.
fix/premium-username-user-state-overriden (#7099)
alannnc0f76530c11b7
diff --git a/apps/web/components/ui/UsernameAvailability/index.tsx b/apps/web/components/ui/UsernameAvailability/index.tsxindex dbc587b7713..2a673e2ea24 100644--- a/apps/web/components/ui/UsernameAvailability/index.tsx+++ b/apps/web/components/ui/UsernameAvailability/index.tsx@@ -1,3 +1,5 @@+import { useRouter } from "next/router";+import { useState } from "react";import { Controller, useForm } from "react-hook-form";import { IS_SELF_HOSTED } from "@calcom/lib/constants";@@ -22,7 +24,13 @@ export const UsernameAvailabilityField = ({onErrorMutation,user,}: UsernameAvailabilityFieldProps) => {- const { username: currentUsername, setQuery: setCurrentUsername } = useRouterQuery("username");+ const router = useRouter();+ const [currentUsernameState, setCurrentUsernameState] = useState(user.username || "");+ const { username: usernameFromQuery, setQuery: setUsernameFromQuery } = useRouterQuery("username");+ const { username: currentUsername, setQuery: setCurrentUsername } =+ router.query["username"] && user.username === null+ ? { username: usernameFromQuery, setQuery: setUsernameFromQuery }+ : { username: currentUsernameState || "", setQuery: setCurrentUsernameState };const formMethods = useForm({defaultValues: {username: currentUsername,