This commit is contained in:
2025-12-14 11:12:18 +03:30
parent 163b4742a0
commit a1c74a78a9
3 changed files with 16 additions and 15 deletions
@@ -5,15 +5,19 @@ import { OrderCreatedEvent } from '../events/order.events';
import { Permission } from 'src/common/enums/permission.enum';
import { NotifTitleEnum } from 'src/modules/notifications/interfaces/notification.interface';
import { NotificationService } from 'src/modules/notifications/services/notification.service';
import { ConfigService } from '@nestjs/config';
@Injectable()
export class OrderListeners {
private readonly logger = new Logger(OrderListeners.name);
private orderCreatedSmsTemplateId: string;
constructor(
private readonly adminService: AdminRepository,
private readonly notificationService: NotificationService,
) {}
private readonly configService: ConfigService,
) {
this.orderCreatedSmsTemplateId = this.configService.get<string>('ORDER_CREATED_SMS_TEMPLATE_ID') ?? '123';
}
@OnEvent(OrderCreatedEvent.name)
async handleOrderCreated(event: OrderCreatedEvent) {
@@ -21,7 +25,7 @@ export class OrderListeners {
this.logger.log(
`Order created event received: ${event.orderId} for restaurant: ${event.restaurantId} and order number: ${event.orderNumber}`,
);
// get admnin os restuaraant that have pager permissuins
// get admnin os restuaraant that have order permissuins
const admins = await this.adminService.findAdminsWithPermission(event.restaurantId, Permission.MANAGE_ORDERS);
const recipients = admins.map(admin => ({
adminId: admin.id,
@@ -32,7 +36,7 @@ export class OrderListeners {
title: NotifTitleEnum.ORDER_CREATED,
content: `Order ${event.orderNumber} has been created successfully`,
sms: {
templateId: '1234567890',
templateId: this.orderCreatedSmsTemplateId,
parameters: {
orderNumber: event.orderNumber,
},
@@ -54,7 +58,7 @@ export class OrderListeners {
});
} catch (error) {
this.logger.error(
`Failed to send notification for pager created event: ${event.restaurantId}`,
`Failed to send notification for order created event: ${event.restaurantId}`,
error instanceof Error ? error.stack : String(error),
);
}
+5 -5
View File
@@ -1,11 +1,6 @@
import { IsString, IsOptional, IsBoolean } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
/**
* DTO for updating user profile.
* Mirrors fields defined on the User entity and keeps everything optional
* to allow partial updates.
*/
export class UpdateUserDto {
@ApiPropertyOptional({ description: "User's first name", example: 'John' })
@IsOptional()
@@ -32,4 +27,9 @@ export class UpdateUserDto {
@IsOptional()
@IsBoolean()
gender?: boolean;
@ApiPropertyOptional({ description: 'Avatar URL' })
@IsOptional()
@IsString()
avatarUrl?: string;
}
+2 -5
View File
@@ -42,11 +42,8 @@ export class User extends BaseEntity {
@Property({ default: true })
gender?: boolean;
// @Property({ default: 0, type: 'int' })
// wallet: number = 0;
// @Property({ default: 0, type: 'int' })
// points: number = 0;
@Property({ nullable: true })
avatarUrl?: string;
@OneToMany(() => UserAddress, address => address.user, {
cascade: [Cascade.ALL],