Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FirstName & LastName first chracter should be capitalized #774

Open
chavda-bhavik opened this issue Sep 2, 2024 · 4 comments · May be fixed by #801
Open

FirstName & LastName first chracter should be capitalized #774

chavda-bhavik opened this issue Sep 2, 2024 · 4 comments · May be fixed by #801
Labels

Comments

@chavda-bhavik
Copy link
Member

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
Copy link

JotaceCode commented Sep 4, 2024

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
Copy link
Member Author

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

@chavda-bhavik
Copy link
Member Author

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

@JotaceCode
Copy link

Ok let me do the pr!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Roadmap
Development

Successfully merging a pull request may close this issue.

2 participants