mirror of
https://fast.feibisi.com/https://github.com/parcelvoy/platform.git
synced 2025-08-28 11:46:02 +08:00
Improves parsing of phone numbers during user import (#636)
This commit is contained in:
parent
9e89e815e3
commit
6e1ef5f76c
1 changed files with 11 additions and 1 deletions
|
@ -62,11 +62,21 @@ const cleanRow = (row: Record<string, any>): Record<string, any> => {
|
|||
|
||||
const cleanCell = (value: any, key: string) => {
|
||||
if (typeof value === 'string') {
|
||||
|
||||
// Parse booleans stored in a string
|
||||
if (value.toLowerCase() === 'false') return false
|
||||
if (value.toLowerCase() === 'true') return true
|
||||
|
||||
// Parse undefined and null stored in a string
|
||||
if (value === 'NULL' || value == null || value === 'undefined' || value === '') return undefined
|
||||
|
||||
// Parse dates stored in a string
|
||||
if (key.includes('_at')) return new Date(value)
|
||||
if (key === 'phone' && !value.includes('+')) return `+${value}`
|
||||
}
|
||||
|
||||
// Handle missformatted phone numbers
|
||||
if (key === 'phone') {
|
||||
return `+${String(value).replace(/\D/g, '')}`
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue