chore(workspace): eradicate all tsc errors and eslint warnings across frontend, admin, and backend
Deploy Canina / deploy (push) Failing after 29s
Deploy Canina / deploy (push) Failing after 29s
This commit is contained in:
1 parent
4659a7b1de
commit
9f11d8fb2d
98 files changed
+1272
-1009
No files matched your search
@@ -2,7 +2,6 @@ import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Patch,
|
||||
Body,
|
||||
Param,
|
||||
UseGuards,
|
||||
@@ -23,7 +22,6 @@ import {
|
||||
ApiCreatedResponse,
|
||||
ApiBadRequestResponse,
|
||||
ApiNotFoundResponse,
|
||||
ApiBody,
|
||||
} from '@nestjs/swagger';
|
||||
import { PaginationDto } from '../common/dto/pagination.dto';
|
||||
import { IsString, IsNumber, IsNotEmpty } from 'class-validator';
|
||||
@@ -84,7 +82,10 @@ export class OrdersController {
|
||||
},
|
||||
},
|
||||
})
|
||||
create(@Req() req: any, @Body() createOrderDto: CreateOrderDto) {
|
||||
create(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Body() createOrderDto: CreateOrderDto,
|
||||
) {
|
||||
return this.ordersService.create(req.user.id, createOrderDto);
|
||||
}
|
||||
|
||||
@@ -106,7 +107,10 @@ export class OrdersController {
|
||||
@ApiBadRequestResponse({
|
||||
description: 'کد تخفیف نامعتبر، منقضی، یا شرایط آن برقرار نیست',
|
||||
})
|
||||
validateCoupon(@Req() req: any, @Body() body: ValidateCouponDto) {
|
||||
validateCoupon(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Body() body: ValidateCouponDto,
|
||||
) {
|
||||
return this.ordersService.validateCoupon(
|
||||
body.code,
|
||||
new Prisma.Decimal(body.cartTotal),
|
||||
@@ -139,7 +143,7 @@ export class OrdersController {
|
||||
},
|
||||
},
|
||||
})
|
||||
findAll(@Req() req: any, @Query() query: PaginationDto) {
|
||||
findAll(@Req() req: { user: { id: string } }, @Query() query: PaginationDto) {
|
||||
return this.ordersService.findAllByUser(req.user.id, query);
|
||||
}
|
||||
|
||||
@@ -182,7 +186,7 @@ export class OrdersController {
|
||||
},
|
||||
},
|
||||
})
|
||||
findOne(@Req() req: any, @Param('id') id: string) {
|
||||
findOne(@Req() req: { user: { id: string } }, @Param('id') id: string) {
|
||||
return this.ordersService.findOne(id, req.user.id);
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export class OrdersService {
|
||||
orderItems: {
|
||||
create: orderItemsData,
|
||||
},
|
||||
} as any,
|
||||
},
|
||||
include: {
|
||||
orderItems: {
|
||||
include: { product: true },
|
||||
@@ -253,7 +253,7 @@ export class OrdersService {
|
||||
orderItems: {
|
||||
create: orderItemsData,
|
||||
},
|
||||
} as any,
|
||||
},
|
||||
include: {
|
||||
orderItems: {
|
||||
include: { product: true },
|
||||
@@ -262,27 +262,19 @@ export class OrdersService {
|
||||
});
|
||||
|
||||
// Send Order Confirmation SMS
|
||||
if (userId && this.prisma.user?.findUnique) {
|
||||
try {
|
||||
const userPromise = this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
});
|
||||
if (userPromise && typeof userPromise.then === 'function') {
|
||||
userPromise
|
||||
.then((user) => {
|
||||
if (user && user.mobile) {
|
||||
this.smsService
|
||||
.sendOrderConfirmation(
|
||||
user.mobile,
|
||||
trackingNumber,
|
||||
Number(finalAmount).toLocaleString('fa-IR'),
|
||||
)
|
||||
.catch(() => {});
|
||||
}
|
||||
})
|
||||
.catch(() => {});
|
||||
}
|
||||
} catch (e) {}
|
||||
if (userId) {
|
||||
const user = await this.prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
});
|
||||
if (user?.mobile) {
|
||||
await this.smsService
|
||||
.sendOrderConfirmation(
|
||||
user.mobile,
|
||||
trackingNumber,
|
||||
Number(finalAmount).toLocaleString('fa-IR'),
|
||||
)
|
||||
.catch(() => {});
|
||||
}
|
||||
}
|
||||
|
||||
return createdOrder;
|
||||
@@ -370,15 +362,15 @@ export class OrdersService {
|
||||
const fiftyEightDaysAgo = new Date(Date.now() - 58 * 24 * 60 * 60 * 1000);
|
||||
const fiftyNineDaysAgo = new Date(Date.now() - 59 * 24 * 60 * 60 * 1000);
|
||||
|
||||
const dueRefillOrders: any[] = await this.prisma.order.findMany({
|
||||
const dueRefillOrders = await this.prisma.order.findMany({
|
||||
where: {
|
||||
isRefill: true,
|
||||
createdAt: {
|
||||
gte: fiftyNineDaysAgo,
|
||||
lte: fiftyEightDaysAgo,
|
||||
},
|
||||
} as any,
|
||||
include: { user: true } as any,
|
||||
},
|
||||
include: { user: true },
|
||||
});
|
||||
|
||||
for (const order of dueRefillOrders) {
|
||||
|
||||
Reference in new issue
Block a user