Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(dashboard): accept a country code in parentheses
Yudhi Armyndharis63dd253b3dfb
diff --git a/dashboard/src/pages/Sessions.test.ts b/dashboard/src/pages/Sessions.test.tsindex 7243b1539..9626b41c1 100644--- a/dashboard/src/pages/Sessions.test.ts+++ b/dashboard/src/pages/Sessions.test.ts@@ -815,6 +815,8 @@ test('the pairing phone field accepts formatted numbers whole and refuses text w['(021) 555 0100', '0215550100'],['+62\u00a0812.3456.7890', '6281234567890'],[' +1 (555) 123-4567 ', '15551234567'],+ ['(+62) 812-3456-7890', '6281234567890'],+ ['(+1) 5551234567', '15551234567'],];for (const [pasted, digits] of accepted) {fireEvent.change(phoneInput, { target: { value: pasted } });@@ -828,6 +830,7 @@ test('the pairing phone field accepts formatted numbers whole and refuses text w'+62 812-3456-7890 ext. 12','62812abc3456','+62 812 +3456 7890',+ '(+62) +812-3456-7890',];for (const pasted of refused) {fireEvent.change(phoneInput, { target: { value: pasted } });diff --git a/dashboard/src/pages/Sessions.tsx b/dashboard/src/pages/Sessions.tsxindex 1743e1a9a..f6e787641 100644--- a/dashboard/src/pages/Sessions.tsx+++ b/dashboard/src/pages/Sessions.tsx@@ -70,9 +70,9 @@ function restrictionTitle(restriction: AccountRestriction, t: TFunction): string// The most digits a phone number has. A longer paste is kept whole and refused, never cut to a number nobody typed.const PAIRING_PHONE_MAX_DIGITS = 15;-// What a number may be written with besides its digits: a leading plus, spaces (a no-break space included), hyphens,-// dots and parentheses.-const PHONE_FORMATTING = /^\+?[\d\s().-]*$/;+// What a number may be written with besides its digits: a plus, spaces (a no-break space included), hyphens, dots and+// parentheses. The plus comes first, but may follow an opening parenthesis, as in "(+62) 812-3456-7890".+const PHONE_FORMATTING = /^[\s(]*\+?[\d\s().-]*$/;// A number written that way is read to its digits. Any other text (a letter, an extension, a sentence around the// number) is kept as pasted and refused, since joining its digit groups would make a number nobody typed.const readPairingPhone = (text: string) => {