supertokens-auth-react icon indicating copy to clipboard operation
supertokens-auth-react copied to clipboard

Make it easier to reorder fields in the sign up form

Open rishabhpoddar opened this issue 4 years ago • 1 comments

Related to conversation https://discord.com/channels/603466164219281420/644849840475602944/867716322334867476

At the moment, we need to use @emotion/react for it and need to override the sign up component and do:

css={{
  form: {
    display: "flex",
    flexDirection: "column",
    "& > div:nth-of-type(3)": { // first name field (for example)
      order: -1
    },
  }
}}>

This is annoying and unclear. We would ideally like an API like:

signUpForm: {
   formFields: [
      {
         id: "name",
         label: "Full Name",
         placeholder: "e.g Jane Doe"
       },
       {
          id: "email"
       },
       {
          id: "password"
       }
   ],
},

Notice that we do not have to provide any other field in the email and password objects. Just their ids.

rishabhpoddar avatar Jul 22 '21 10:07 rishabhpoddar

Just tried this and it worked nicely for me:

EmailPasswordSignUp_Override: ({ DefaultComponent, ...props }) => {
      return (
              <DefaultComponent
                    {...props}
                    formFields={[
                       props.formFields.find(({id}) => id === 'name'),
                       props.formFields.find(({id}) => id === 'email'),
                       props.formFields.find(({id}) => id === 'password'),
                    ]}
              />
       );
},

nickmanks avatar Sep 03 '22 13:09 nickmanks

This has been solved now: https://supertokens.com/docs/thirdpartyemailpassword/common-customizations/signup-form/customising-each-form-field#changing-field-order--pre

rishabhpoddar avatar Feb 09 '24 07:02 rishabhpoddar