Skip to content

Commit

Permalink
fix: refactor last commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mirovladimitrovski committed Sep 25, 2023
1 parent 053da25 commit 4236dc4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/services/inplayer.account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,25 +91,25 @@ export const register: Register = async ({ config, email, password, customFields
const metadata = {
...customFields,
...Object.entries(customFields).reduce((acc, [name, val]) => {
const isBoolean = val === true || val === false;
const value = (() => {
if (name === 'us_state') {
if (customFields.country === 'us') {
return val === 'n/a' ? '' : val;
}

if (isBoolean) {
if (name === 'terms') {
return { ...acc, [name]: val };
return 'n/a';
}

return { ...acc, [name]: val === true ? 'on' : 'off' };
}
const isBoolean = val === true || val === false;

if (name === 'us_state') {
if (customFields.country === 'us') {
return { ...acc, [name]: val === 'n/a' ? '' : val };
if (isBoolean && name !== 'terms') {
return val === true ? 'on' : 'off';
}

return { ...acc, [name]: 'n/a' };
}
return val;
})();

return { ...acc, [name]: val };
return { ...acc, [name]: value };
}, {}),
};

Expand Down

0 comments on commit 4236dc4

Please sign in to comment.