Chat settings in Super Admin and changing the chat title and position.

This commit is contained in:
2026-09-29 14:45:19 +03:30
parent 125976f3eb
commit 66af7e577c
14 changed files with 332 additions and 269 deletions
@@ -3,9 +3,66 @@ import { Cron } from '@nestjs/schedule';
import { Prisma } from '@prisma/client';
import type { LeadImportJobDto } from '@mento/shared';
import { PrismaService } from '../prisma/prisma.service';
import {
parseExcelMapping,
previewExcel,
readMappedRows,
type ExcelFieldOption,
type ExcelPreviewResult,
} from '../common/excel';
import { LeadStagesService } from './lead-stages.service';
import { LeadsService } from './leads.service';
const LEAD_ALIASES: Record<string, string> = {
title: 'title',
name: 'title',
shop: 'title',
نام: 'title',
نامفروشگاه: 'title',
فروشگاه: 'title',
عنوان: 'title',
contactname: 'contactName',
owner: 'contactName',
مالک: 'contactName',
مسئول: 'contactName',
ناممالک: 'contactName',
ناممخاطب: 'contactName',
mobile: 'mobile',
phone: 'mobile',
tel: 'mobile',
موبایل: 'mobile',
شماره: 'mobile',
شمارهتماس: 'mobile',
تلفن: 'phone',
تلفنثابت: 'phone',
city: 'city',
شهر: 'city',
region: 'region',
منطقه: 'region',
محله: 'region',
trade: 'trade',
صنف: 'trade',
رسته: 'trade',
source: 'source',
منبع: 'source',
منبعلید: 'source',
notes: 'notes',
توضیحات: 'notes',
یادداشت: 'notes',
};
const LEAD_FIELDS: ExcelFieldOption[] = [
{ key: 'title', label: 'نام / فروشگاه', required: true },
{ key: 'mobile', label: 'موبایل', required: true },
{ key: 'contactName', label: 'نام مخاطب / مالک' },
{ key: 'phone', label: 'تلفن' },
{ key: 'city', label: 'شهر' },
{ key: 'region', label: 'منطقه' },
{ key: 'trade', label: 'صنف' },
{ key: 'source', label: 'منبع' },
{ key: 'notes', label: 'توضیحات' },
];
@Injectable()
export class LeadsImportService {
private readonly logger = new Logger(LeadsImportService.name);
@@ -17,6 +74,22 @@ export class LeadsImportService {
private readonly leads: LeadsService,
) {}
preview(file: Express.Multer.File): Promise<ExcelPreviewResult> {
return previewExcel(file, LEAD_ALIASES, LEAD_FIELDS);
}
async rowsFromFile(
file: Express.Multer.File,
mappingRaw?: string,
): Promise<Array<Record<string, string>>> {
const rows = await readMappedRows(
file,
LEAD_ALIASES,
parseExcelMapping(mappingRaw),
);
return rows.map((r) => this.normalizeRow(r));
}
async enqueue(
organizationId: string,
createdById: string,