fix(build): resolve linter and tsconfig project service errors, guarantee dist/main existence in start-dev
Deploy Canina / deploy (push) Has been cancelled
Deploy Canina / deploy (push) Has been cancelled
This commit is contained in:
1 parent
a291fa0c4a
commit
6362750dea
50 files changed
+12128
-10959
No files matched your search
@@ -119,9 +119,20 @@ export class AdminService {
|
||||
}
|
||||
}
|
||||
|
||||
const sortField = (query.sortBy && typeof query.sortBy === 'string' && ['createdAt', 'firstName', 'lastName', 'mobile', 'email', 'role', 'walletBalance'].includes(query.sortBy))
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortField =
|
||||
query.sortBy &&
|
||||
typeof query.sortBy === 'string' &&
|
||||
[
|
||||
'createdAt',
|
||||
'firstName',
|
||||
'lastName',
|
||||
'mobile',
|
||||
'email',
|
||||
'role',
|
||||
'walletBalance',
|
||||
].includes(query.sortBy)
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortDirection = query.sortOrder === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
@@ -167,7 +178,9 @@ export class AdminService {
|
||||
where: { mobile },
|
||||
});
|
||||
if (existingMobile) {
|
||||
throw new BadRequestException('کاربری با این شماره موبایل قبلاً در سیستم ثبت شده است');
|
||||
throw new BadRequestException(
|
||||
'کاربری با این شماره موبایل قبلاً در سیستم ثبت شده است',
|
||||
);
|
||||
}
|
||||
|
||||
if (dto.email) {
|
||||
@@ -175,12 +188,16 @@ export class AdminService {
|
||||
where: { email: dto.email.trim().toLowerCase() },
|
||||
});
|
||||
if (existingEmail) {
|
||||
throw new BadRequestException('کاربری با این آدرس ایمیل قبلاً در سیستم ثبت شده است');
|
||||
throw new BadRequestException(
|
||||
'کاربری با این آدرس ایمیل قبلاً در سیستم ثبت شده است',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const passwordToHash = dto.password?.trim();
|
||||
const hashedPassword = passwordToHash ? await bcrypt.hash(passwordToHash, 10) : '';
|
||||
const hashedPassword = passwordToHash
|
||||
? await bcrypt.hash(passwordToHash, 10)
|
||||
: '';
|
||||
|
||||
return this.prisma.user.create({
|
||||
data: {
|
||||
@@ -200,7 +217,9 @@ export class AdminService {
|
||||
|
||||
async updateUser(id: string, dto: UpdateUserDto) {
|
||||
if (id === '12345678-1234-1234-1234-123456789012') {
|
||||
throw new BadRequestException('امکان ویرایش حساب ادمین پیشفرض وجود ندارد');
|
||||
throw new BadRequestException(
|
||||
'امکان ویرایش حساب ادمین پیشفرض وجود ندارد',
|
||||
);
|
||||
}
|
||||
|
||||
const user = await this.prisma.user.findUnique({ where: { id } });
|
||||
@@ -208,31 +227,41 @@ export class AdminService {
|
||||
throw new NotFoundException(`کاربری با شناسه ${id} یافت نشد`);
|
||||
}
|
||||
|
||||
const normalizedMobile = dto.mobile ? normalizeMobile(dto.mobile) : undefined;
|
||||
const normalizedMobile = dto.mobile
|
||||
? normalizeMobile(dto.mobile)
|
||||
: undefined;
|
||||
if (normalizedMobile && normalizedMobile !== user.mobile) {
|
||||
const existingMobile = await this.prisma.user.findUnique({
|
||||
where: { mobile: normalizedMobile },
|
||||
});
|
||||
if (existingMobile && existingMobile.id !== id) {
|
||||
throw new BadRequestException('این شماره موبایل متعلق به کاربر دیگری است');
|
||||
throw new BadRequestException(
|
||||
'این شماره موبایل متعلق به کاربر دیگری است',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const normalizedEmail = dto.email ? dto.email.trim().toLowerCase() : undefined;
|
||||
const normalizedEmail = dto.email
|
||||
? dto.email.trim().toLowerCase()
|
||||
: undefined;
|
||||
if (normalizedEmail && normalizedEmail !== user.email) {
|
||||
const existingEmail = await this.prisma.user.findUnique({
|
||||
where: { email: normalizedEmail },
|
||||
});
|
||||
if (existingEmail && existingEmail.id !== id) {
|
||||
throw new BadRequestException('این آدرس ایمیل متعلق به کاربر دیگری است');
|
||||
throw new BadRequestException(
|
||||
'این آدرس ایمیل متعلق به کاربر دیگری است',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const updateData: Prisma.UserUpdateInput = {};
|
||||
if (dto.firstName !== undefined) updateData.firstName = dto.firstName.trim();
|
||||
if (dto.firstName !== undefined)
|
||||
updateData.firstName = dto.firstName.trim();
|
||||
if (dto.lastName !== undefined) updateData.lastName = dto.lastName.trim();
|
||||
if (normalizedMobile !== undefined) updateData.mobile = normalizedMobile;
|
||||
if (normalizedEmail !== undefined) updateData.email = normalizedEmail || null;
|
||||
if (normalizedEmail !== undefined)
|
||||
updateData.email = normalizedEmail || null;
|
||||
if (dto.role !== undefined) updateData.role = dto.role;
|
||||
if (dto.walletBalance !== undefined) {
|
||||
updateData.walletBalance = new Prisma.Decimal(dto.walletBalance);
|
||||
@@ -319,16 +348,28 @@ export class AdminService {
|
||||
}
|
||||
|
||||
if (query.suitableFor && query.suitableFor !== 'all') {
|
||||
andConditions.push({ suitableFor: { in: [query.suitableFor, 'سگ و گربه', 'هر دو'] } });
|
||||
andConditions.push({
|
||||
suitableFor: { in: [query.suitableFor, 'سگ و گربه', 'هر دو'] },
|
||||
});
|
||||
}
|
||||
|
||||
if (andConditions.length > 0) {
|
||||
where.AND = andConditions;
|
||||
}
|
||||
|
||||
const sortField = (query.sortBy && typeof query.sortBy === 'string' && ['nameFa', 'artNo', 'priceValue', 'packageSize', 'createdAt', 'updatedAt'].includes(query.sortBy))
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortField =
|
||||
query.sortBy &&
|
||||
typeof query.sortBy === 'string' &&
|
||||
[
|
||||
'nameFa',
|
||||
'artNo',
|
||||
'priceValue',
|
||||
'packageSize',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
].includes(query.sortBy)
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortDirection = query.sortOrder === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
@@ -366,7 +407,8 @@ export class AdminService {
|
||||
categorySlug: data.categorySlug || 'general',
|
||||
buyPrice: data.buyPrice !== undefined ? data.buyPrice : 0,
|
||||
priceValue: data.priceValue || 0,
|
||||
wholesalePrice: data.wholesalePrice !== undefined ? data.wholesalePrice : null,
|
||||
wholesalePrice:
|
||||
data.wholesalePrice !== undefined ? data.wholesalePrice : null,
|
||||
priceDisplay: data.priceDisplay || '',
|
||||
unit: data.unit || 'عدد',
|
||||
packageSize: data.packageSize || 100,
|
||||
@@ -431,7 +473,8 @@ export class AdminService {
|
||||
categorySlug: data.categorySlug,
|
||||
buyPrice: data.buyPrice !== undefined ? data.buyPrice : undefined,
|
||||
priceValue: data.priceValue,
|
||||
wholesalePrice: data.wholesalePrice !== undefined ? data.wholesalePrice : undefined,
|
||||
wholesalePrice:
|
||||
data.wholesalePrice !== undefined ? data.wholesalePrice : undefined,
|
||||
priceDisplay: data.priceDisplay,
|
||||
unit: data.unit,
|
||||
packageSize: data.packageSize,
|
||||
@@ -444,16 +487,25 @@ export class AdminService {
|
||||
? [data.images]
|
||||
: undefined,
|
||||
podcastUrl: data.podcastUrl !== undefined ? data.podcastUrl : undefined,
|
||||
podcastTitle: data.podcastTitle !== undefined ? data.podcastTitle : undefined,
|
||||
podcastDescription: data.podcastDescription !== undefined ? data.podcastDescription : undefined,
|
||||
podcastCover: data.podcastCover !== undefined ? data.podcastCover : undefined,
|
||||
podcastTitle:
|
||||
data.podcastTitle !== undefined ? data.podcastTitle : undefined,
|
||||
podcastDescription:
|
||||
data.podcastDescription !== undefined
|
||||
? data.podcastDescription
|
||||
: undefined,
|
||||
podcastCover:
|
||||
data.podcastCover !== undefined ? data.podcastCover : undefined,
|
||||
videoUrl: data.videoUrl !== undefined ? data.videoUrl : undefined,
|
||||
videoTitle: data.videoTitle !== undefined ? data.videoTitle : undefined,
|
||||
videoDescription: data.videoDescription !== undefined ? data.videoDescription : undefined,
|
||||
videoDescription:
|
||||
data.videoDescription !== undefined
|
||||
? data.videoDescription
|
||||
: undefined,
|
||||
videoCover: data.videoCover !== undefined ? data.videoCover : undefined,
|
||||
pdfUrl: data.pdfUrl !== undefined ? data.pdfUrl : undefined,
|
||||
pdfTitle: data.pdfTitle !== undefined ? data.pdfTitle : undefined,
|
||||
pdfDescription: data.pdfDescription !== undefined ? data.pdfDescription : undefined,
|
||||
pdfDescription:
|
||||
data.pdfDescription !== undefined ? data.pdfDescription : undefined,
|
||||
pdfCover: data.pdfCover !== undefined ? data.pdfCover : undefined,
|
||||
metaTitle: data.metaTitle,
|
||||
metaDescription: data.metaDescription,
|
||||
@@ -506,9 +558,14 @@ export class AdminService {
|
||||
where.status = query.status;
|
||||
}
|
||||
|
||||
const sortField = (query.sortBy && typeof query.sortBy === 'string' && ['createdAt', 'totalAmount', 'status', 'finalAmount'].includes(query.sortBy))
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortField =
|
||||
query.sortBy &&
|
||||
typeof query.sortBy === 'string' &&
|
||||
['createdAt', 'totalAmount', 'status', 'finalAmount'].includes(
|
||||
query.sortBy,
|
||||
)
|
||||
? query.sortBy
|
||||
: 'createdAt';
|
||||
const sortDirection = query.sortOrder === 'asc' ? 'asc' : 'desc';
|
||||
|
||||
const [data, total] = await Promise.all([
|
||||
|
||||
Reference in new issue
Block a user