Skip to content

Commit

Permalink
fix: trim name and handle multiple whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
darkoatanasovski committed Dec 7, 2022
1 parent 18c3c64 commit 67ccf6a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ export const updateCustomer: UpdateCustomer = async (values) => {
fullName,
metadata: {
...(values?.consents && { consents: JSON.stringify(values.consents) }),
first_name: values.firstName || '',
surname: values.lastName || '',
first_name: values.firstName?.replace(/\s\s+/g, ' ').trim() || '',
surname: values.lastName?.replace(/\s\s+/g, ' ')?.trim() || '',
},
});

Expand All @@ -84,8 +84,8 @@ function processAccount(account: AccountData): Customer {
let lastName = metadata?.surname as string;
if (!firstName && !lastName) {
const nameParts = fullName.split(' ');
firstName = nameParts[0] || '';
lastName = nameParts.slice(1).join(' ');
firstName = nameParts[0]?.trim() || '';
lastName = nameParts.slice(1)?.join(' ');
}
return {
id: id.toString(),
Expand Down

0 comments on commit 67ccf6a

Please sign in to comment.