From 9edbb92b13c345cf2f7141a30441ec95bb17e91b Mon Sep 17 00:00:00 2001 From: Mahdi Date: Sun, 27 Sep 2026 19:51:02 +0330 Subject: [PATCH] Align Leads header with Contacts and add phone-contact lead import. Leads actions mirror people import/export, and create-lead can fill fields from device contacts like Person form. --- .../src/components/PhoneContactsImport.vue | 45 +- apps/web/src/views/LeadsView.vue | 499 ++++++++++++++---- 2 files changed, 441 insertions(+), 103 deletions(-) diff --git a/apps/web/src/components/PhoneContactsImport.vue b/apps/web/src/components/PhoneContactsImport.vue index cd9b628..aaee99e 100644 --- a/apps/web/src/components/PhoneContactsImport.vue +++ b/apps/web/src/components/PhoneContactsImport.vue @@ -15,9 +15,14 @@ import { type PhoneContactDraft, } from '@/lib/phone-contacts'; -defineProps<{ - disabled?: boolean; -}>(); +const props = withDefaults( + defineProps<{ + disabled?: boolean; + /** people = اشخاص | leads = لیدها */ + target?: 'people' | 'leads'; + }>(), + { target: 'people' }, +); const emit = defineEmits<{ start: []; @@ -171,15 +176,30 @@ async function importSelected() { let failed = 0; try { for (const row of rows) { - const body: CreatePersonRequest = { - firstName: row.firstName, - lastName: row.lastName || undefined, - mobile: row.mobile, - phone: row.phone, - email: row.email, - }; try { - await api.post('/people', body); + if (props.target === 'leads') { + const mobile = row.mobile || row.phone; + if (!mobile) { + failed += 1; + continue; + } + await api.post('/leads', { + title: row.fullName, + contactName: row.fullName, + mobile, + phone: row.phone && row.phone !== mobile ? row.phone : null, + source: 'مخاطبین گوشی', + }); + } else { + const body: CreatePersonRequest = { + firstName: row.firstName, + lastName: row.lastName || undefined, + mobile: row.mobile, + phone: row.phone, + email: row.email, + }; + await api.post('/people', body); + } created += 1; } catch (e) { if (axios.isAxiosError(e) && e.response?.status === 409) { @@ -315,7 +335,8 @@ async function importSelected() { @click="importSelected" > - ورود {{ toFaDigits(selectedCount) }} نفر + ورود {{ toFaDigits(selectedCount) }} + {{ target === 'leads' ? 'لید' : 'نفر' }} diff --git a/apps/web/src/views/LeadsView.vue b/apps/web/src/views/LeadsView.vue index 6847b2c..601c188 100644 --- a/apps/web/src/views/LeadsView.vue +++ b/apps/web/src/views/LeadsView.vue @@ -1,5 +1,5 @@