fix: unable to update username (#25221)
* unable to update username * update * Add import for useEffect and useState hooks
This commit is contained in:
@@ -6,7 +6,6 @@ import { Controller, useForm } from "react-hook-form";
|
||||
|
||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
||||
import { WEBSITE_URL, IS_SELF_HOSTED } from "@calcom/lib/constants";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
import { trpc } from "@calcom/trpc/react";
|
||||
import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
|
||||
|
||||
@@ -42,9 +41,7 @@ export const UsernameAvailability = (props: ICustomUsernameProps) => {
|
||||
const { isPremium, disabled, ...otherProps } = props;
|
||||
const UsernameAvailabilityComponent = isPremium ? PremiumTextfield : UsernameTextfield;
|
||||
// PremiumTextfield uses `readonly` prop, UsernameTextfield uses `disabled` prop
|
||||
const componentProps = isPremium
|
||||
? { ...otherProps, readonly: disabled }
|
||||
: { ...otherProps, disabled };
|
||||
const componentProps = isPremium ? { ...otherProps, readonly: disabled } : { ...otherProps, disabled };
|
||||
return <UsernameAvailabilityComponent {...componentProps} />;
|
||||
};
|
||||
|
||||
@@ -63,7 +60,7 @@ export const UsernameAvailabilityField = ({
|
||||
: { username: currentUsernameState || "", setQuery: setCurrentUsernameState };
|
||||
const formMethods = useForm({
|
||||
defaultValues: {
|
||||
username: slugify(currentUsername || user.username || ""),
|
||||
username: currentUsername,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -85,11 +82,7 @@ export const UsernameAvailabilityField = ({
|
||||
setCurrentUsername={setCurrentUsername}
|
||||
inputUsernameValue={value}
|
||||
usernameRef={ref}
|
||||
setInputUsernameValue={(val) => {
|
||||
const displayValue = slugify(val, true);
|
||||
formMethods.setValue("username", displayValue);
|
||||
onChange?.(displayValue);
|
||||
}}
|
||||
setInputUsernameValue={onChange}
|
||||
onSuccessMutation={onSuccessMutation}
|
||||
onErrorMutation={onErrorMutation}
|
||||
disabled={disabled ?? !!user.organization?.id}
|
||||
|
||||
Reference in New Issue
Block a user