1
0
forked from test/crm

fix: save copy of all contacts

This commit is contained in:
Shariq Ansari 2024-01-24 23:21:53 +05:30
parent 234f443107
commit c39588e228
2 changed files with 10 additions and 2 deletions

View File

@ -110,7 +110,7 @@ const props = defineProps({
const values = defineModel() const values = defineModel()
const { contacts } = contactsStore() const { getContacts } = contactsStore()
const emails = ref([]) const emails = ref([])
const search = ref(null) const search = ref(null)
@ -119,8 +119,9 @@ const query = ref('')
const showOptions = ref(false) const showOptions = ref(false)
const emailList = computed(() => { const emailList = computed(() => {
let contacts = getContacts() || []
return ( return (
contacts.data contacts
?.filter((contact) => contact.email_id) ?.filter((contact) => contact.email_id)
.map((contact) => { .map((contact) => {
return { return {

View File

@ -6,6 +6,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
let contactsByPhone = reactive({}) let contactsByPhone = reactive({})
let contactsByName = reactive({}) let contactsByName = reactive({})
let leadContactsByPhone = reactive({}) let leadContactsByPhone = reactive({})
let allContacts = reactive([])
const contacts = createResource({ const contacts = createResource({
url: 'crm.api.session.get_contacts', url: 'crm.api.session.get_contacts',
@ -20,6 +21,7 @@ export const contactsStore = defineStore('crm-contacts', () => {
contactsByPhone[contact.mobile_no] = contact contactsByPhone[contact.mobile_no] = contact
contactsByName[contact.name] = contact contactsByName[contact.name] = contact
} }
allContacts = [...contacts]
return contacts return contacts
}, },
onError(error) { onError(error) {
@ -63,8 +65,13 @@ export const contactsStore = defineStore('crm-contacts', () => {
return leadContactsByPhone[mobile_no] return leadContactsByPhone[mobile_no]
} }
function getContacts() {
return allContacts || contacts?.data || []
}
return { return {
contacts, contacts,
getContacts,
getContact, getContact,
getContactByName, getContactByName,
getLeadContact, getLeadContact,