Skip to content

Commit

Permalink
fix: set default email as fullname for InPlayer integration if first …
Browse files Browse the repository at this point in the history
…and last names are empty
  • Loading branch information
darkoatanasovski committed Jan 24, 2023
1 parent bc4cec9 commit 22f6640
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,13 +345,9 @@ function processAccount(account: AccountData): Customer {
const { id, uuid, email, full_name: fullName, metadata, created_at: createdAt } = account;
const regDate = new Date(createdAt * 1000).toLocaleString();

let firstName = metadata?.first_name as string;
let lastName = metadata?.surname as string;
if (!firstName && !lastName) {
const nameParts = fullName.split(' ');
firstName = nameParts[0] || '';
lastName = nameParts.slice(1)?.join(' ');
}
const firstName = metadata?.first_name as string;
const lastName = metadata?.surname as string;

return {
id: id.toString(),
uuid,
Expand All @@ -371,7 +367,7 @@ function processUpdateAccount(customer: UpdateCustomerArgs) {
const lastName = customer.lastName?.trim() || '';
let fullName = `${firstName} ${lastName}`;
if (!firstName && !lastName) {
fullName = '[EMPTY FULL NAME]';
fullName = customer.email as string;
}
const data: UpdateAccountData = {
fullName,
Expand Down
2 changes: 1 addition & 1 deletion src/stores/AccountController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export async function updateUser(values: FirstLastNameInput | EmailConfirmPasswo
};
}

const response = await accountService.updateCustomer({ ...values, id: user.id.toString() }, sandbox, auth.jwt);
const response = await accountService.updateCustomer({ ...{ ...values, email: user.email }, id: user.id.toString() }, sandbox, auth.jwt);

if (!response) {
throw new Error('Unknown error');
Expand Down

0 comments on commit 22f6640

Please sign in to comment.