fix(linter): resolve all linter rules and type errors across 3 subprojects
This commit is contained in:
1 parent
5f790a60a9
commit
a1f0640483
17 files changed
+201
-104
No files matched your search
@@ -39,7 +39,9 @@ export class AdminService {
|
||||
const [dogCount, catCount, bothCount] = await Promise.all([
|
||||
this.prisma.product.count({ where: { suitableFor: 'سگ' } }),
|
||||
this.prisma.product.count({ where: { suitableFor: 'گربه' } }),
|
||||
this.prisma.product.count({ where: { suitableFor: { contains: 'هر دو' } } }),
|
||||
this.prisma.product.count({
|
||||
where: { suitableFor: { contains: 'هر دو' } },
|
||||
}),
|
||||
]);
|
||||
|
||||
return {
|
||||
@@ -51,7 +53,7 @@ export class AdminService {
|
||||
{ name: 'مکمل سگ', value: dogCount || 8 },
|
||||
{ name: 'مکمل گربه', value: catCount || 6 },
|
||||
{ name: 'هر دو (سگ و گربه)', value: bothCount || 12 },
|
||||
]
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -156,7 +158,11 @@ export class AdminService {
|
||||
dosageLogic: data.dosageLogic,
|
||||
suitableFor: data.suitableFor,
|
||||
imageUrl: data.imageUrl,
|
||||
images: Array.isArray(data.images) ? data.images : (data.images ? [data.images] : []),
|
||||
images: Array.isArray(data.images)
|
||||
? data.images
|
||||
: data.images
|
||||
? [data.images]
|
||||
: [],
|
||||
podcastUrl: data.podcastUrl || null,
|
||||
videoUrl: data.videoUrl || null,
|
||||
pdfUrl: data.pdfUrl || null,
|
||||
@@ -436,11 +442,26 @@ export class AdminService {
|
||||
});
|
||||
}
|
||||
|
||||
async createDoctor(data: { name: string; title: string; avatarUrl?: string; bio?: string; clinic?: string }) {
|
||||
async createDoctor(data: {
|
||||
name: string;
|
||||
title: string;
|
||||
avatarUrl?: string;
|
||||
bio?: string;
|
||||
clinic?: string;
|
||||
}) {
|
||||
return this.prisma.doctor.create({ data });
|
||||
}
|
||||
|
||||
async updateDoctor(id: string, data: { name?: string; title?: string; avatarUrl?: string; bio?: string; clinic?: string }) {
|
||||
async updateDoctor(
|
||||
id: string,
|
||||
data: {
|
||||
name?: string;
|
||||
title?: string;
|
||||
avatarUrl?: string;
|
||||
bio?: string;
|
||||
clinic?: string;
|
||||
},
|
||||
) {
|
||||
return this.prisma.doctor.update({ where: { id }, data });
|
||||
}
|
||||
|
||||
|
||||
@@ -50,10 +50,18 @@ export class MediaController {
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Put(':id')
|
||||
@ApiOperation({ summary: 'ویرایش متادیتای سئوی فایل (Alt, Title, Description, Caption)' })
|
||||
@ApiOperation({
|
||||
summary: 'ویرایش متادیتای سئوی فایل (Alt, Title, Description, Caption)',
|
||||
})
|
||||
async updateMedia(
|
||||
@Param('id') id: string,
|
||||
@Body() body: { altText?: string; title?: string; description?: string; caption?: string },
|
||||
@Body()
|
||||
body: {
|
||||
altText?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
caption?: string;
|
||||
},
|
||||
) {
|
||||
const data = await this.mediaService.updateMedia(id, body);
|
||||
return { success: true, data };
|
||||
|
||||
@@ -62,7 +62,15 @@ export class MediaService {
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
async updateMedia(id: string, data: { altText?: string; title?: string; description?: string; caption?: string }) {
|
||||
async updateMedia(
|
||||
id: string,
|
||||
data: {
|
||||
altText?: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
caption?: string;
|
||||
},
|
||||
) {
|
||||
return this.prisma.media.update({
|
||||
where: { id },
|
||||
data: {
|
||||
|
||||
@@ -27,7 +27,11 @@ export class RolesGuard implements CanActivate {
|
||||
}
|
||||
|
||||
const userRoleLower = user.role.toLowerCase();
|
||||
const hasRole = requiredRoles.some(r => r.toLowerCase() === userRoleLower || (userRoleLower.includes('admin') && r.toLowerCase().includes('admin')));
|
||||
const hasRole = requiredRoles.some(
|
||||
(r) =>
|
||||
r.toLowerCase() === userRoleLower ||
|
||||
(userRoleLower.includes('admin') && r.toLowerCase().includes('admin')),
|
||||
);
|
||||
if (!hasRole) {
|
||||
throw new ForbiddenException('سطح دسترسی شما کافی نیست');
|
||||
}
|
||||
|
||||
@@ -49,10 +49,15 @@ export class CustomHttpExceptionFilter implements ExceptionFilter {
|
||||
};
|
||||
});
|
||||
} else {
|
||||
const rawMsg = typeof resObj.message === 'string' ? resObj.message : exception.message;
|
||||
const rawMsg =
|
||||
typeof resObj.message === 'string'
|
||||
? resObj.message
|
||||
: exception.message;
|
||||
message = this.translateGenericMessage(rawMsg, status);
|
||||
const rawCode = typeof resObj.code === 'string' ? resObj.code : undefined;
|
||||
const rawError = typeof resObj.error === 'string' ? resObj.error : undefined;
|
||||
const rawCode =
|
||||
typeof resObj.code === 'string' ? resObj.code : undefined;
|
||||
const rawError =
|
||||
typeof resObj.error === 'string' ? resObj.error : undefined;
|
||||
code = rawCode || this.deriveErrorCode(status, rawError);
|
||||
details = (resObj.details as Record<string, unknown>) || {};
|
||||
}
|
||||
|
||||
@@ -83,7 +83,10 @@ export class SmsService {
|
||||
* Send OTP Verification Code (Pattern 508079)
|
||||
*/
|
||||
async sendOtp(phone: string, otpCode: string): Promise<boolean> {
|
||||
const bodyId = parseInt(process.env.MELIPAYAMAK_OTP_BODY_ID || '508079', 10);
|
||||
const bodyId = parseInt(
|
||||
process.env.MELIPAYAMAK_OTP_BODY_ID || '508079',
|
||||
10,
|
||||
);
|
||||
return this.sendPatternSms({
|
||||
to: phone,
|
||||
bodyId,
|
||||
@@ -99,7 +102,10 @@ export class SmsService {
|
||||
orderNumber: string,
|
||||
amount: string,
|
||||
): Promise<boolean> {
|
||||
const bodyId = parseInt(process.env.MELIPAYAMAK_ORDER_BODY_ID || '508081', 10);
|
||||
const bodyId = parseInt(
|
||||
process.env.MELIPAYAMAK_ORDER_BODY_ID || '508081',
|
||||
10,
|
||||
);
|
||||
return this.sendPatternSms({
|
||||
to: phone,
|
||||
bodyId,
|
||||
|
||||
@@ -13,7 +13,6 @@ import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../auth/roles.guard';
|
||||
import { Roles } from '../auth/roles.decorator';
|
||||
|
||||
|
||||
@Controller('contact')
|
||||
export class ContactController {
|
||||
constructor(private readonly contactService: ContactService) {}
|
||||
|
||||
@@ -10,4 +10,3 @@ import { SmsModule } from '../common/sms.module';
|
||||
exports: [ContactService],
|
||||
})
|
||||
export class ContactModule {}
|
||||
|
||||
@@ -40,7 +40,10 @@ export class ContactService {
|
||||
|
||||
// Send SMS confirmation to User & notification to Admin
|
||||
try {
|
||||
const userPatternId = parseInt(process.env.MELIPAYAMAK_CONTACT_USER_BODY_ID || '508081', 10);
|
||||
const userPatternId = parseInt(
|
||||
process.env.MELIPAYAMAK_CONTACT_USER_BODY_ID || '508081',
|
||||
10,
|
||||
);
|
||||
await this.smsService.sendPatternSms({
|
||||
to: dto.phone,
|
||||
bodyId: userPatternId,
|
||||
@@ -48,19 +51,25 @@ export class ContactService {
|
||||
});
|
||||
|
||||
const adminPhone = process.env.ADMIN_MOBILE || '09364100228';
|
||||
const adminPatternId = parseInt(process.env.MELIPAYAMAK_CONTACT_ADMIN_BODY_ID || '508083', 10);
|
||||
const adminPatternId = parseInt(
|
||||
process.env.MELIPAYAMAK_CONTACT_ADMIN_BODY_ID || '508083',
|
||||
10,
|
||||
);
|
||||
await this.smsService.sendPatternSms({
|
||||
to: adminPhone,
|
||||
bodyId: adminPatternId,
|
||||
args: [dto.name, dto.phone],
|
||||
});
|
||||
} catch (err) {
|
||||
this.logger.error(`SMS trigger error on contact submission: ${err.message}`);
|
||||
this.logger.error(
|
||||
`SMS trigger error on contact submission: ${err.message}`,
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'پیام شما با موفقیت ثبت شد و بهزودی کارشناسان ما با شما تماس خواهند گرفت.',
|
||||
message:
|
||||
'پیام شما با موفقیت ثبت شد و بهزودی کارشناسان ما با شما تماس خواهند گرفت.',
|
||||
submissionId: submission.id,
|
||||
};
|
||||
}
|
||||
@@ -76,7 +85,8 @@ export class ContactService {
|
||||
{
|
||||
key: 'branch_info',
|
||||
title: 'اطلاعات نمایندگی',
|
||||
value: 'تلفنهای تماس\n۰۲۱-۸۸۸۸ ۴۴۴۴\n\nشنبه تا چهارشنبه ۹:۰۰ الی ۱۸:۰۰',
|
||||
value:
|
||||
'تلفنهای تماس\n۰۲۱-۸۸۸۸ ۴۴۴۴\n\nشنبه تا چهارشنبه ۹:۰۰ الی ۱۸:۰۰',
|
||||
icon: 'phone',
|
||||
order: 1,
|
||||
},
|
||||
@@ -135,7 +145,11 @@ export class ContactService {
|
||||
};
|
||||
}
|
||||
|
||||
async updateSubmissionStatus(id: string, status: string, adminNotes?: string) {
|
||||
async updateSubmissionStatus(
|
||||
id: string,
|
||||
status: string,
|
||||
adminNotes?: string,
|
||||
) {
|
||||
return this.prisma.contactSubmission.update({
|
||||
where: { id },
|
||||
data: { status, adminNotes },
|
||||
|
||||
Reference in new issue
Block a user