implerhq / impler.io

Powerful CSV & Excel Import experience for SaaS 🚀 Save months building data import experience from scratch 💰
https://impler.io
MIT License
202 stars 33 forks source link

FirstName & LastName first chracter should be capitalized #774

Open chavda-bhavik opened 2 months ago

chavda-bhavik commented 2 months ago

Is your feature request related to a problem? Please describe. If the user signs up, his/her first and last name should have the first letter in uppercase and other letters should be in lowercase.

Describe the solution you'd like We can do an update in the signup form to send the formatted name in the backend.

JotaceCode commented 2 months ago

I think this can solve the problem with the name and surname:

/**
   * Name formater to capitalize the first letter
   * @param name string to capitalize
   * @returns a string with the name with capital letter at char position 0
   */
  const formatName = (name: string): string => {
    if (!name) return '';
    return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
  };

  /** 
   * Now we can send the info in the right format to the back end
  */
  const onSignup = (data: ISignupFormData) => {
    const nameParts = data.fullName.trim().split(' ');// We save the name parts as an array with the fristName and the lastName

    const firstName = formatName(nameParts[0]);
    const lastName = nameParts.length > 1 ? formatName(nameParts.slice(1).join(' ')) : '';

    const signupData: ISignupData = {
      firstName: firstName, 
      lastName: lastName,   
      email: data.email,
      password: data.password,
    };

    signup(signupData);
  }; 
chavda-bhavik commented 1 month ago

@JotaceCode Looking awesome. Would you like to create a merge request for it? Thanks for taking a look.

chavda-bhavik commented 1 month ago

@JotaceCode I can assign this issue to you if you like.

JotaceCode commented 1 month ago

Ok let me do the pr!