import { Button, Checkbox, Input, Row, notification } from "antd"; import { ErrorResponse, UserCreateRequest, UserUpdateRequest } from "@newstackdev/iosdk-newgraph-client-js"; import { SyntheticEvent, useEffect, useRef, useState } from "react"; import Form from "antd/lib/form"; // import { logout } from "./Auth"; import { ContentLayout } from "../../Components/ContentLayout"; import { CrossCircle } from "../../Components/Icons/CrossCircle"; import { EmbeddableControl, NLView } from "../../types"; import { FieldData } from "rc-field-form/lib/interface"; import { IndeterminateProgress, IndeterminateProgressAction } from "../../Components/IndeterminateProgress"; import { ProgressButton } from "../../Components/ProgressButton"; import { RowCheckbox } from "../../Components/RowCheckbox"; import { User } from "@firebase/auth"; import { assert } from "console"; import { useActions, useAppState, useEffects } from "../../overmind"; import { useCachedPoolByCode } from "../../hooks/useCached"; import { useForm } from "antd/lib/form/Form"; import { useHistory } from "react-router-dom"; import isEmpty from "lodash/isEmpty"; import isNil from "lodash/isNil"; import omitBy from "lodash/omitBy"; import pick from "lodash/pick"; const defaultCreateFormValues = [ "consentEmail", "consentTestgroup", "description", "discord", "displayName", "email", "facebook", "id", "instagram", "pinterest", "soundcloud", "tumblr", "twitter", "website", "youtube", ]; export const CrossCircleErr: NLView<{ children?: JSX.Element }> = ({ children }) => { return ( <> {children}
); }; export const UserCreate: NLView< EmbeddableControl & { hideUsername?: boolean; noRouing?: boolean; } > = ({ hideUsername, noRouing, embedded, setNext }) => { const state = useAppState(); const actions = useActions(); const effects = useEffects(); const [isEmailAvailable, setIsEmailAvailable] = useState(false); const ticker = useCachedPoolByCode({ code: state.flows.user.create.form.newcoinTicker?.toUpperCase() }); const [form] = useForm(); const username = state.flows.user.create.form.username; useEffect(() => { actions.routing.setBreadcrumbs([{ text: "Create your profile" }]); // For imported users, if they have email, they should not be able to change it setIsEmailAvailable(!isEmpty(state.flows.user.create.form.email)); }, []); const setNextEmbedded = () => { (!state.api.auth.user?.username || state.flows.user.create.legacyToken) && //["invited", "imported", "known"].includes(state.api.auth.user.status || "") && setNext && setNext({ text: "Next", command: () => form.submit(), }); return () => setNext && setNext(undefined); }; const sf = state.flows.user.create.form; useEffect(setNextEmbedded, [sf]); const onFinish = async (values: UserCreateRequest) => { const defaultUser = { username: "", newcoinTicker: "", displayName: "", email: "", description: "", website: "", twitter: "", discord: "", instagram: "", tumblr: "", soundcloud: "", consentPrivacyPolicy: "", phone: "", legacyToken: "", }; console.log("Creating:", values); try { await form.validateFields(); } catch (e: any) { console.log(e.errorFields.length); return; } if (state.flows.user.create.metamaskFlow) { await actions.api.user.update({ user: { ...pick(state.api.auth.user, defaultCreateFormValues), id: state.api.auth.user.id || "", ...values, }, }); actions.routing.historyPush({ location: "/explore" }); return; } actions.flows.user.create.create({ noRouting: !!noRouing, user: { ...defaultUser, ...omitBy(values, isNil), }, }); }; // const onFinishFailed = (errorInfo: any) => { // console.log('Failed:', errorInfo); // effects.ux.message.error(JSON.stringify(errorInfo)) // }; const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; return (

{username}

{ const upd = _ch.reduce( (r, c: FieldData) => // @ts-ignore ({ ...r, [c.name[0]]: c.value || c.values }), sf as Partial, ); actions.flows.user.create.updateForm(upd as UserCreateRequest); }} initialValues={sf} > { if (ticker) { return Promise.reject(new Error("Ticker already exists! Choose another one.")); } return Promise.resolve(); }, }, ]} > } /> } /> {/* } /> */} } disabled={isEmailAvailable && state.flows.user.create.isLegacyUpdateOngoing} /> {/* } /> */}

You can add or edit socials later!

I agree to Newlife's{" "} privacy policy

I consent to email communications

I want to help the team improve the app

{/* */}
); }; // function logout() { // throw new Error("Function not implemented."); // }