fix: save copy of all contacts
This commit is contained in:
parent
234f443107
commit
c39588e228
@ -110,7 +110,7 @@ const props = defineProps({
|
||||
|
||||
const values = defineModel()
|
||||
|
||||
const { contacts } = contactsStore()
|
||||
const { getContacts } = contactsStore()
|
||||
|
||||
const emails = ref([])
|
||||
const search = ref(null)
|
||||
@ -119,8 +119,9 @@ const query = ref('')
|
||||
const showOptions = ref(false)
|
||||
|
||||
const emailList = computed(() => {
|
||||
let contacts = getContacts() || []
|
||||
return (
|
||||
contacts.data
|
||||
contacts
|
||||
?.filter((contact) => contact.email_id)
|
||||
.map((contact) => {
|
||||
return {
|
||||
|
||||
@ -6,6 +6,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
|
||||
let contactsByPhone = reactive({})
|
||||
let contactsByName = reactive({})
|
||||
let leadContactsByPhone = reactive({})
|
||||
let allContacts = reactive([])
|
||||
|
||||
const contacts = createResource({
|
||||
url: 'crm.api.session.get_contacts',
|
||||
@ -20,6 +21,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
|
||||
contactsByPhone[contact.mobile_no] = contact
|
||||
contactsByName[contact.name] = contact
|
||||
}
|
||||
allContacts = [...contacts]
|
||||
return contacts
|
||||
},
|
||||
onError(error) {
|
||||
@ -63,8 +65,13 @@ export const contactsStore = defineStore('crm-contacts', () => {
|
||||
return leadContactsByPhone[mobile_no]
|
||||
}
|
||||
|
||||
function getContacts() {
|
||||
return allContacts || contacts?.data || []
|
||||
}
|
||||
|
||||
return {
|
||||
contacts,
|
||||
getContacts,
|
||||
getContact,
|
||||
getContactByName,
|
||||
getLeadContact,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user