Skip to content

Commit 358b873

Browse files
authored
fix: unable to update username (calcom#25221)
* unable to update username * update * Add import for useEffect and useState hooks
1 parent 44aa262 commit 358b873

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

  • apps/web/components/ui/UsernameAvailability

apps/web/components/ui/UsernameAvailability/index.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { Controller, useForm } from "react-hook-form";
66

77
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
88
import { WEBSITE_URL, IS_SELF_HOSTED } from "@calcom/lib/constants";
9-
import slugify from "@calcom/lib/slugify";
109
import { trpc } from "@calcom/trpc/react";
1110
import type { AppRouter } from "@calcom/trpc/types/server/routers/_app";
1211

@@ -42,9 +41,7 @@ export const UsernameAvailability = (props: ICustomUsernameProps) => {
4241
const { isPremium, disabled, ...otherProps } = props;
4342
const UsernameAvailabilityComponent = isPremium ? PremiumTextfield : UsernameTextfield;
4443
// PremiumTextfield uses `readonly` prop, UsernameTextfield uses `disabled` prop
45-
const componentProps = isPremium
46-
? { ...otherProps, readonly: disabled }
47-
: { ...otherProps, disabled };
44+
const componentProps = isPremium ? { ...otherProps, readonly: disabled } : { ...otherProps, disabled };
4845
return <UsernameAvailabilityComponent {...componentProps} />;
4946
};
5047

@@ -63,7 +60,7 @@ export const UsernameAvailabilityField = ({
6360
: { username: currentUsernameState || "", setQuery: setCurrentUsernameState };
6461
const formMethods = useForm({
6562
defaultValues: {
66-
username: slugify(currentUsername || user.username || ""),
63+
username: currentUsername,
6764
},
6865
});
6966

@@ -85,11 +82,7 @@ export const UsernameAvailabilityField = ({
8582
setCurrentUsername={setCurrentUsername}
8683
inputUsernameValue={value}
8784
usernameRef={ref}
88-
setInputUsernameValue={(val) => {
89-
const displayValue = slugify(val, true);
90-
formMethods.setValue("username", displayValue);
91-
onChange?.(displayValue);
92-
}}
85+
setInputUsernameValue={onChange}
9386
onSuccessMutation={onSuccessMutation}
9487
onErrorMutation={onErrorMutation}
9588
disabled={disabled ?? !!user.organization?.id}

0 commit comments

Comments
 (0)