1
0
forked from test/crm

fix: do not parse mobile no if not exist

This commit is contained in:
Shariq Ansari 2024-01-17 17:47:42 +05:30
parent ec80e3704f
commit f3ebc4b853

View File

@ -16,7 +16,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
for (let contact of contacts) {
// remove special characters from phone number to make it easier to search
// also remove spaces but keep + sign at the start
contact.mobile_no = contact.mobile_no.replace(/[^0-9+]/g, '')
contact.mobile_no = contact.mobile_no?.replace(/[^0-9+]/g, '')
contactsByPhone[contact.mobile_no] = contact
contactsByName[contact.name] = contact
}
@ -52,7 +52,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
})
function getContact(mobile_no) {
mobile_no = mobile_no.replace(/[^0-9+]/g, '')
mobile_no = mobile_no?.replace(/[^0-9+]/g, '')
return contactsByPhone[mobile_no]
}
function getContactByName(name) {