import { AppearingComponent } from "../../Components/Appearing"; import { Button, Tag, Tooltip } from "antd"; import { ContentLayout } from "../../Components/ContentLayout"; import { IOView } from "../../types"; import { Link } from "react-router-dom"; import { MaskedInput } from "antd-mask-input"; import { NextButton } from "./NextButton"; import { RefObject, SyntheticEvent, useEffect, useRef } from "react"; import { SpaceSpin } from "../../Components/Spin"; import { estimateUsernamePrice } from "../../utils/username"; import { isEmpty } from "lodash"; import { useActions, useAppState } from "../../overmind"; import Paragraph from "antd/lib/typography/Paragraph"; export const DomainSelector: IOView = () => { const actions = useActions(); const state = useAppState(); const fuia = state.flows.user.create.formUsernameIsAvailable; const isMetamaskFlow = state.flows.user.create.metamaskFlow; const el: RefObject = useRef({} as typeof MaskedInput); const username = state.flows.user.create.form.username || ""; useEffect(() => { if (state.flows.user.create.isLegacyUpdateOngoing) { actions.flows.user.create.updateForm({ ...state.api.auth.user }); } }, [state.api.auth.user]); const domainPrice = () => estimateUsernamePrice(username); const isPaidUsername = () => { const len = username.replace(/\.io/, "").length; const couponCode = state.flows.user.create.form.couponCode; return ( len > 1 && len <= 5 && !state.api.auth.user?.subscriptionStatus?.startsWith("io-domain-sale") && !(couponCode === "NEWFORUM-100-DROP1307" || couponCode === "LONDONX" || couponCode === "LONDON22") ); }; const isOneChar = () => { const len = username.replace(/\.io/, "").length; return len === 1 && !state.api.auth.user?.subscriptionStatus?.startsWith("io-domain-sale"); }; return (

Choose a name for your new life. It will be your account and wallet ID to receive crypto payments. This cannot be changed or deleted, and you own it. 9 characters max: a-z and 1-5.

{ actions.flows.user.create.updateForm({ username: v.target.value.replace(/\u200c/g, "").toLowerCase(), }); }} formatCharacters={{ x: { validate: function (char: string) { return /^[a-zA-Z1-5\.]$/.test(char); }, }, }} />
{fuia === "checking" && } {fuia === "unavailable" && Name is {fuia}} {isOneChar() && !isMetamaskFlow ? ( To purchase a one character domain please{" "} contact us . ) : ( <> )} {isPaidUsername() && !state.flows.user.create.legacyToken && !isMetamaskFlow ? (
{state.config.featureFlags.onboarding.premiumDomains ? ( <> Premium usernames of 5 and fewer characters must be purchased.
Estimated price: {domainPrice()}
Click Next to continue. ) : ( <> For early access please contact  our support team . )}
) : ( "" )} {state.flows.user.create.legacyToken && !isMetamaskFlow && (state.flows.user.create.form.displayName !== state.flows.user.create.form.username || fuia === "unavailable") ? ( <> Your Newlife identity is now a part of the Newcoin ecosystem and provides access to many exciting services. You may keep your current username as the display name on Newlife on the next dialog. } > Why is my username changing?   actions.flows.user.create.stopLegacyImport()}> I am not {state.flows.user.create.legacyUsername || state.api.auth.user.username} ) : ( "" )}
) } /> {/* )} */}
); };