normalize

This commit is contained in:
2025-12-06 22:46:53 +03:30
parent 01631c147a
commit 46470f73d0
+10 -1
View File
@@ -1,6 +1,7 @@
import { Entity, ManyToOne, Property, Enum, Unique } from '@mikro-orm/core';
import { BaseEntity } from '../../../common/entities/base.entity';
import { Restaurant } from '../../restaurants/entities/restaurant.entity';
import { normalizePhone } from '../../utils/phone.util';
export enum CouponType {
PERCENTAGE = 'PERCENTAGE',
@@ -58,6 +59,14 @@ export class Coupon extends BaseEntity {
@Property({ type: 'json', nullable: true })
foods?: string[]; // Array of food IDs
private _userPhone?: string;
@Property({ nullable: true })
userPhone?: string; // Phone number of the user who can use this coupon
get userPhone(): string | undefined {
return this._userPhone;
}
set userPhone(value: string | undefined) {
this._userPhone = value ? normalizePhone(value) : undefined;
}
}