Standardize phone number formatting in member service and MembersView

Integrated phone number standardization in the member service to ensure consistent formatting during member updates and contact creation. Added a new utility function in MembersView for phone number standardization, enhancing data integrity and user experience when adding or updating member information.
This commit is contained in:
Torsten Schulz (local)
2025-11-06 16:45:44 +01:00
parent 9cdbd60a23
commit fc7b70b307
3 changed files with 277 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ import fs from 'fs';
import sharp from 'sharp';
import { devLog } from '../utils/logger.js';
import { standardizePhoneNumber } from '../utils/phoneUtils.js';
class MemberService {
async getApprovalRequests(userToken, clubId) {
await checkAccess(userToken, clubId);
@@ -93,7 +94,7 @@ class MemberService {
member.city = city;
if (postalCode !== undefined) member.postalCode = postalCode;
member.birthDate = birthdate;
member.phone = phone;
member.phone = phone ? standardizePhoneNumber(phone) : phone;
member.email = email;
member.active = active;
member.testMembership = testMembership;
@@ -111,10 +112,15 @@ class MemberService {
// Create new contacts
for (const contact of contacts) {
if (contact.value && contact.type) {
// Standardisiere Telefonnummern
let standardizedValue = contact.value;
if (contact.type === 'phone') {
standardizedValue = standardizePhoneNumber(contact.value);
}
await MemberContact.create({
memberId: member.id,
type: contact.type,
value: contact.value,
value: standardizedValue,
isParent: contact.isParent || false,
parentName: contact.parentName || null,
isPrimary: contact.isPrimary || false
@@ -130,7 +136,7 @@ class MemberService {
city: city,
postalCode: postalCode || null,
birthDate: birthdate,
phone: phone,
phone: phone ? standardizePhoneNumber(phone) : phone,
email: email,
clubId: clubId,
active: active,
@@ -146,10 +152,15 @@ class MemberService {
if (Array.isArray(contacts)) {
for (const contact of contacts) {
if (contact.value && contact.type) {
// Standardisiere Telefonnummern
let standardizedValue = contact.value;
if (contact.type === 'phone') {
standardizedValue = standardizePhoneNumber(contact.value);
}
await MemberContact.create({
memberId: newMember.id,
type: contact.type,
value: contact.value,
value: standardizedValue,
isParent: contact.isParent || false,
parentName: contact.parentName || null,
isPrimary: contact.isPrimary || false