2
0

🚸 (phone) Improve phone input behavior and validation

Now accepting landline phone numbers. Consistent select UI on every browser. Auto focus on country select.
This commit is contained in:
Baptiste Arnaud
2023-03-09 14:19:39 +01:00
parent bf1fbf2c53
commit 6b08df71ba
10 changed files with 70 additions and 41 deletions

View File

@ -1,4 +1,4 @@
import phone from 'phone'
import { parsePhoneNumber } from 'libphonenumber-js'
export const formatPhoneNumber = (phoneNumber: string) =>
phone(phoneNumber).phoneNumber
parsePhoneNumber(phoneNumber).formatInternational()

View File

@ -1,4 +1,4 @@
import { phone } from 'phone'
import { isValidPhoneNumber } from 'libphonenumber-js'
export const validatePhoneNumber = (phoneNumber: string) =>
phone(phoneNumber).isValid
isValidPhoneNumber(phoneNumber)

View File

@ -50,13 +50,13 @@ export const continueBotFlow =
message: 'Current block is not an input block',
})
if (reply && !isReplyValid(reply, block)) return parseRetryMessage(block)
const formattedReply = formatReply(reply, block.type)
if (!formattedReply && !canSkip(block.type)) {
return parseRetryMessage(block)
}
if (formattedReply && !isReplyValid(formattedReply, block))
return parseRetryMessage(block)
const newSessionState = await processAndSaveAnswer(
state,