Ensure currentUsername is set before comparing it with username (#4750)
Co-authored-by: Omar López <zomars@me.com> Co-authored-by: Alan <alannnc@gmail.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>pull/4755/head^2
parent
9304ca1415
commit
5e80f5056d
|
@ -91,11 +91,10 @@ const PremiumTextfield = (props: ICustomUsernameProps) => {
|
|||
const isCurrentUsernamePremium =
|
||||
user && user.metadata && hasKeyInMetadata(user, "isPremium") ? !!user.metadata.isPremium : false;
|
||||
const [isInputUsernamePremium, setIsInputUsernamePremium] = useState(false);
|
||||
|
||||
const debouncedApiCall = useCallback(
|
||||
debounce(async (username) => {
|
||||
debounce(async (username: string) => {
|
||||
const { data } = await fetchUsername(username);
|
||||
setMarkAsError(!data.available && username && username !== currentUsername);
|
||||
setMarkAsError(!data.available && !!currentUsername && username !== currentUsername);
|
||||
setIsInputUsernamePremium(data.premium);
|
||||
setUsernameIsAvailable(data.available);
|
||||
}, 150),
|
||||
|
|
Loading…
Reference in New Issue