From 99df327dedc5da390bd4bcc57a35ada49f75ecb0 Mon Sep 17 00:00:00 2001 From: Mahdi Date: Wed, 23 Sep 2026 14:41:16 +0330 Subject: [PATCH] Adding two fields to the mesh form --- .../migration.sql | 3 +++ apps/api/prisma/schema.prisma | 4 ++++ apps/api/src/contacts/dto.ts | 20 +++++++++++++++++++ apps/api/src/contacts/people.service.ts | 8 ++++++++ apps/web/src/views/PersonFormView.vue | 14 +++++++++++++ apps/web/src/views/PersonProfileView.vue | 6 ++++++ packages/shared/src/index.ts | 4 ++++ 7 files changed, 59 insertions(+) create mode 100644 apps/api/prisma/migrations/20260923140000_person_website_referrer/migration.sql diff --git a/apps/api/prisma/migrations/20260923140000_person_website_referrer/migration.sql b/apps/api/prisma/migrations/20260923140000_person_website_referrer/migration.sql new file mode 100644 index 0000000..2ee1ef4 --- /dev/null +++ b/apps/api/prisma/migrations/20260923140000_person_website_referrer/migration.sql @@ -0,0 +1,3 @@ +-- AlterTable +ALTER TABLE "Person" ADD COLUMN "website" TEXT; +ALTER TABLE "Person" ADD COLUMN "referrer" TEXT; diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index 040cfa6..8e0f630 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -362,6 +362,10 @@ model Person { phone String? mobile String? position String? + /// آدرس وب‌سایت + website String? + /// نام معرف + referrer String? notes String? mood PersonMood @default(newcomer) customFields Json @default("{}") diff --git a/apps/api/src/contacts/dto.ts b/apps/api/src/contacts/dto.ts index 3070c35..d82e742 100644 --- a/apps/api/src/contacts/dto.ts +++ b/apps/api/src/contacts/dto.ts @@ -165,6 +165,16 @@ export class CreatePersonDto { @MaxLength(120) position?: string; + @IsOptional() + @IsString() + @MaxLength(300) + website?: string; + + @IsOptional() + @IsString() + @MaxLength(120) + referrer?: string; + @IsOptional() @IsString() @MaxLength(2000) @@ -220,6 +230,16 @@ export class UpdatePersonDto { @MaxLength(120) position?: string; + @IsOptional() + @IsString() + @MaxLength(300) + website?: string; + + @IsOptional() + @IsString() + @MaxLength(120) + referrer?: string; + @IsOptional() @IsString() @MaxLength(2000) diff --git a/apps/api/src/contacts/people.service.ts b/apps/api/src/contacts/people.service.ts index 81f7d6d..c7c3c8e 100644 --- a/apps/api/src/contacts/people.service.ts +++ b/apps/api/src/contacts/people.service.ts @@ -44,6 +44,8 @@ type PersonRow = { phone: string | null; mobile: string | null; position: string | null; + website: string | null; + referrer: string | null; notes: string | null; mood: PersonMood; customFields: unknown; @@ -140,6 +142,8 @@ export class PeopleService { phone: normalizePhone(dto.phone), mobile: normalizePhone(dto.mobile), position: emptyToNull(dto.position), + website: emptyToNull(dto.website), + referrer: emptyToNull(dto.referrer), notes: emptyToNull(dto.notes), mood: dto.mood ?? 'newcomer', companyId, @@ -185,6 +189,8 @@ export class PeopleService { if ('phone' in dto) data.phone = normalizePhone(dto.phone); if ('mobile' in dto) data.mobile = normalizePhone(dto.mobile); if ('position' in dto) data.position = emptyToNull(dto.position); + if ('website' in dto) data.website = emptyToNull(dto.website); + if ('referrer' in dto) data.referrer = emptyToNull(dto.referrer); if ('notes' in dto) data.notes = emptyToNull(dto.notes); if (dto.mood !== undefined) data.mood = dto.mood; if ('customFields' in dto) { @@ -268,6 +274,8 @@ export class PeopleService { phone: row.phone, mobile: row.mobile, position: row.position, + website: row.website, + referrer: row.referrer, notes: row.notes, mood: row.mood, customFields: asCustomFields(row.customFields), diff --git a/apps/web/src/views/PersonFormView.vue b/apps/web/src/views/PersonFormView.vue index de63a41..9099466 100644 --- a/apps/web/src/views/PersonFormView.vue +++ b/apps/web/src/views/PersonFormView.vue @@ -59,6 +59,8 @@ const email = ref(''); const phone = ref(''); const mobile = ref(''); const position = ref(''); +const website = ref(''); +const referrer = ref(''); const notes = ref(''); const companyId = ref(''); const mood = ref('newcomer'); @@ -200,6 +202,8 @@ function fill(p: PersonDto) { phone.value = p.phone ?? ''; mobile.value = p.mobile ?? ''; position.value = p.position ?? ''; + website.value = p.website ?? ''; + referrer.value = p.referrer ?? ''; notes.value = p.notes ?? ''; companyId.value = p.company?.id ?? ''; mood.value = p.mood || 'newcomer'; @@ -235,6 +239,8 @@ function payload(): CreatePersonRequest { phone: phone.value || undefined, mobile: mobile.value || undefined, position: position.value || undefined, + website: website.value || undefined, + referrer: referrer.value || undefined, notes: notes.value || undefined, companyId: companyId.value || null, mood: mood.value, @@ -422,6 +428,14 @@ onMounted(load); + + + + + + + +
diff --git a/apps/web/src/views/PersonProfileView.vue b/apps/web/src/views/PersonProfileView.vue index 41b011d..63acd6e 100644 --- a/apps/web/src/views/PersonProfileView.vue +++ b/apps/web/src/views/PersonProfileView.vue @@ -331,6 +331,8 @@ const infoEmpty = computed(() => { !p.phone && !p.email && !p.position && + !p.website && + !p.referrer && !p.company && !p.notes?.trim() && !tickets.value.length @@ -603,6 +605,8 @@ watch(() => route.query.tab, readTab, { immediate: true });
سمت
{{ person.position || '—' }}
+
وب‌سایت
{{ person.website || '—' }}
+
معرف
{{ person.referrer || '—' }}
شرکت
{{ person.company?.name || '—' }}
تلفن
{{ phoneDisplay }}
ایمیل
{{ emailDisplay }}
@@ -876,6 +880,8 @@ watch(() => route.query.tab, readTab, { immediate: true });
تلفن
{{ person.phone ? toFaDigits(person.phone) : '—' }}
ایمیل
{{ person.email || '—' }}
سمت
{{ person.position || '—' }}
+
وب‌سایت
{{ person.website || '—' }}
+
معرف
{{ person.referrer || '—' }}
شرکت
{{ person.company?.name || '—' }}
مسئول
{{ person.owner?.fullName || '—' }}
diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 9f4b56d..fc7f1db 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -629,6 +629,8 @@ export interface PersonDto { phone: string | null; mobile: string | null; position: string | null; + website: string | null; + referrer: string | null; notes: string | null; mood: PersonMood; customFields: Record; @@ -647,6 +649,8 @@ export interface CreatePersonRequest { phone?: string; mobile?: string; position?: string; + website?: string; + referrer?: string; notes?: string; mood?: PersonMood; companyId?: string | null;