Selection of multiple officials and role sub-categories

This commit is contained in:
2026-10-03 13:16:13 +03:30
parent 9f97371391
commit 3b128bd980
14 changed files with 904 additions and 95 deletions
@@ -109,6 +109,7 @@ export class ActivitiesExcelService {
company: { select: { id: true, name: true } },
deal: { select: { id: true, title: true } },
assignee: { select: { fullName: true } },
assignees: { select: { fullName: true } },
createdBy: { select: { fullName: true } },
},
orderBy: [{ dueAt: 'desc' }, { createdAt: 'desc' }],
@@ -124,7 +125,9 @@ export class ActivitiesExcelService {
title: row.title,
body: row.description ?? '',
result: '',
assignee: row.assignee?.fullName ?? '',
assignee: row.assignees?.length
? row.assignees.map((a) => a.fullName).join('، ')
: (row.assignee?.fullName ?? ''),
creator: row.createdBy?.fullName ?? '',
dueDate: formatJalaliDate(row.dueAt),
dueTime: formatClock(row.dueAt),
@@ -182,8 +185,17 @@ export class ActivitiesExcelService {
const personId = await this.findPersonId(actor.organizationId, row);
const companyId = await this.findCompanyId(actor.organizationId, row.companyName);
const dealId = await this.findDealId(actor.organizationId, row.dealTitle);
const assigneeId =
(await this.findUserId(actor.organizationId, row.assignee)) ?? actor.userId;
const assigneeNames = String(row.assignee ?? '')
.split(/[,،]/)
.map((s) => s.trim())
.filter(Boolean);
const assigneeIds: string[] = [];
for (const name of assigneeNames) {
const uid = await this.findUserId(actor.organizationId, name);
if (uid && !assigneeIds.includes(uid)) assigneeIds.push(uid);
}
if (!assigneeIds.length) assigneeIds.push(actor.userId);
const assigneeId = assigneeIds[0]!;
const creatorId =
(await this.findUserId(actor.organizationId, row.creator)) ?? actor.userId;
@@ -218,6 +230,7 @@ export class ActivitiesExcelService {
companyId,
dealId,
assigneeId,
assignees: { connect: assigneeIds.map((id) => ({ id })) },
createdById: creatorId,
},
});