This commit is contained in:
2026-02-22 17:00:13 +03:30
parent b64e654c08
commit 30c9e9e24a
+7 -15
View File
@@ -63,7 +63,7 @@ export class OrderService {
user = invoiceItem.invoice.user user = invoiceItem.invoice.user
} }
if (!invoiceItem) { if (!invoiceItem) {
if (!dto.userId) { if (!dto.userId) {
@@ -196,12 +196,7 @@ export class OrderService {
await this.em.flush(); await this.em.flush();
} }
async updateStatusAsDesigner(orderId: string, dto: UpdateStatusAsDesignerDto): Promise<Order> {
const order = await this.findOrderOrFail(orderId);
order.status = dto.status;
await this.em.flush();
return order
}
async updateStatus(orderId: string, adminId: string, dto: UpdateStatusDto): Promise<Order> { async updateStatus(orderId: string, adminId: string, dto: UpdateStatusDto): Promise<Order> {
const permissions = await this.adminService.hasPermissions(adminId, const permissions = await this.adminService.hasPermissions(adminId,
@@ -215,17 +210,14 @@ export class OrderService {
} }
if (permissions.includes(PermissionEnum.VIEW_ASSIGNED_ORDERS)) { if (permissions.includes(PermissionEnum.VIEW_ASSIGNED_ORDERS)) {
//TODO
const order = await this.findOrderOrFailAssignedOrder(orderId, adminId); const order = await this.findOrderOrFailAssignedOrder(orderId, adminId);
order.status = dto.status; order.status = dto.status;
await this.em.flush(); await this.em.flush();
return order return order
} }
const order = await this.findOrderOrFail(orderId); throw new ForbiddenException("You don't have permission to update order status")
order.status = dto.status;
await this.em.flush();
return order
} }
async assignDesigner(orderId: string, designerId: string) { async assignDesigner(orderId: string, designerId: string) {
@@ -254,7 +246,7 @@ export class OrderService {
return print; return print;
} }
async getPrint(orderId:string){ async getPrint(orderId: string) {
const orderPrint = await this.orderPrintRepository.findOne({ order: { id: orderId } }); const orderPrint = await this.orderPrintRepository.findOne({ order: { id: orderId } });
if (!orderPrint) { if (!orderPrint) {
throw new NotFoundException(`Print with ID ${orderId} not found.`); throw new NotFoundException(`Print with ID ${orderId} not found.`);
@@ -264,7 +256,7 @@ export class OrderService {
// -----------Hrlper Methods ----------- // -----------Hrlper Methods -----------
async findOrderOrFail(id: string): Promise<Order> { async findOrderOrFail(id: string): Promise<Order> {
const order = await this.em.findOne(Order, { id }, { populate: ['user', 'type', 'product', 'creator', 'print'] }); const order = await this.em.findOne(Order, { id }, { populate: ['user', 'type', 'product', 'creator', 'designer'] });
if (!order) { if (!order) {
throw new NotFoundException(`Order with ID ${id} not found.`); throw new NotFoundException(`Order with ID ${id} not found.`);
} }