Skip to content

Commit

Permalink
format phone numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
nimarion committed May 27, 2024
1 parent 87cc959 commit ded9396
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@sentry/node": "^7.81.0",
"@sentry/tracing": "^7.81.0",
"graphql-request": "^6.1.0",
"libphonenumber-js": "^1.11.2",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.5",
"rxjs": "^7.8.1",
Expand Down
12 changes: 8 additions & 4 deletions src/athlete_representatives/athlete_representatives.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from './athlete_representatives.query';
import { z } from 'zod';
import { formatLastname } from 'src/name.utils';
import parsePhoneNumber from 'libphonenumber-js';

@Injectable()
export class AthleteRepresentativesService {
Expand Down Expand Up @@ -57,6 +58,12 @@ export class AthleteRepresentativesService {
if (!response.getAthleteRepresentativeProfile) {
return null;
}

const phoneNumber =
response.getAthleteRepresentativeProfile.mobile.length > 0
? parsePhoneNumber(response.getAthleteRepresentativeProfile.mobile[0])
: null;

return {
country: response.getAthleteRepresentativeProfile.countryCode,
email:
Expand All @@ -69,10 +76,7 @@ export class AthleteRepresentativesService {
lastname: formatLastname(
response.getAthleteRepresentativeProfile.lastName,
),
phone:
response.getAthleteRepresentativeProfile.mobile.length > 0
? response.getAthleteRepresentativeProfile.mobile[0]
: null,
phone: phoneNumber ? phoneNumber.formatInternational() : null,
id: response.getAthleteRepresentativeProfile.athleteRepresentativeId,
};
}
Expand Down

0 comments on commit ded9396

Please sign in to comment.