feat(leads): keep gender on leads and form submissions
A lead can carry the same honorific as a person, and a form that asks gender writes it onto the lead. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -77,9 +77,10 @@ import type {
|
||||
LeadStageDto,
|
||||
LeadStatsDto,
|
||||
OrgUserDto,
|
||||
PersonGender,
|
||||
PaginatedResponse,
|
||||
} from '@mento/shared';
|
||||
import { brand } from '@mento/shared';
|
||||
import { brand, PERSON_GENDERS, PERSON_GENDER_LABELS, splitPersonHonorific } from '@mento/shared';
|
||||
|
||||
const { Title: ATypographyTitle, Text: ATypographyText, Paragraph: ATypographyParagraph } =
|
||||
Typography;
|
||||
@@ -191,6 +192,8 @@ const editingLeadId = ref<string | null>(null);
|
||||
const createForm = ref({
|
||||
title: '',
|
||||
contactName: '',
|
||||
gender: 'none' as PersonGender,
|
||||
showGenderInName: false,
|
||||
mobile: '',
|
||||
city: '',
|
||||
region: '',
|
||||
@@ -656,12 +659,31 @@ const createModalTitle = computed(() =>
|
||||
editingLeadId.value ? 'ویرایش لید' : 'ثبت لید جدید',
|
||||
);
|
||||
|
||||
const genderOptions = PERSON_GENDERS.map((key) => ({
|
||||
value: key,
|
||||
label: PERSON_GENDER_LABELS[key],
|
||||
}));
|
||||
|
||||
function bareLeadName(value: string) {
|
||||
const split = splitPersonHonorific(value, '');
|
||||
return [split.firstName, split.lastName].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
watch(
|
||||
() => createForm.value.gender,
|
||||
(value) => {
|
||||
if (value === 'none') createForm.value.showGenderInName = false;
|
||||
},
|
||||
);
|
||||
|
||||
function openCreate() {
|
||||
editingLeadId.value = null;
|
||||
createError.value = '';
|
||||
createForm.value = {
|
||||
title: '',
|
||||
contactName: '',
|
||||
gender: 'none',
|
||||
showGenderInName: false,
|
||||
mobile: '',
|
||||
city: '',
|
||||
region: '',
|
||||
@@ -693,8 +715,10 @@ function openEdit(lead: LeadDto) {
|
||||
editingLeadId.value = lead.id;
|
||||
createError.value = '';
|
||||
createForm.value = {
|
||||
title: lead.title,
|
||||
contactName: lead.contactName ?? '',
|
||||
title: bareLeadName(lead.title),
|
||||
contactName: bareLeadName(lead.contactName ?? ''),
|
||||
gender: lead.gender && lead.gender !== 'none' ? lead.gender : 'none',
|
||||
showGenderInName: !!lead.showGenderInName && lead.gender !== 'none',
|
||||
mobile: lead.mobile,
|
||||
city: lead.city ?? '',
|
||||
region: lead.region ?? '',
|
||||
@@ -857,6 +881,8 @@ async function submitCreate() {
|
||||
title: company || person || mobile,
|
||||
mobile,
|
||||
contactName: person || null,
|
||||
gender: createForm.value.gender,
|
||||
showGenderInName: createForm.value.gender !== 'none' && createForm.value.showGenderInName,
|
||||
city: createForm.value.city.trim() || null,
|
||||
region: createForm.value.region.trim() || null,
|
||||
source: createForm.value.source.trim() || null,
|
||||
@@ -1629,6 +1655,24 @@ onBeforeUnmount(() => {
|
||||
<a-input v-model:value="createForm.contactName" placeholder="مهدی احمدی" style="width: 100%" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item label="جنسیت">
|
||||
<a-select v-model:value="createForm.gender" :options="genderOptions" />
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xs="24" :md="12">
|
||||
<a-form-item
|
||||
label="نمایش در نام"
|
||||
extra="مرد «جناب آقای» و زن «سرکار خانم» ابتدای نام مخاطب ذخیره میشود. اگر نام مخاطب خالی باشد روی عنوان مینشیند و با تبدیل به مشتری به تهحساب هم میرود."
|
||||
>
|
||||
<a-checkbox
|
||||
v-model:checked="createForm.showGenderInName"
|
||||
:disabled="createForm.gender === 'none'"
|
||||
>
|
||||
نمایش در نام
|
||||
</a-checkbox>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :span="24">
|
||||
<a-form-item label="موبایل">
|
||||
<template #extra>
|
||||
|
||||
Reference in New Issue
Block a user