scope for contact
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { IsNotEmpty, IsString, IsOptional, IsMobilePhone } from 'class-validator';
|
import { IsNotEmpty, IsString, IsOptional, IsMobilePhone, IsEnum } from 'class-validator';
|
||||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||||
|
import { ContactScope } from '../interface/interface';
|
||||||
|
|
||||||
export class CreateContactDto {
|
export class CreateContactDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@@ -12,6 +13,11 @@ export class CreateContactDto {
|
|||||||
@ApiProperty({ example: 'I have a question about your menu items', description: 'Contact content/message' })
|
@ApiProperty({ example: 'I have a question about your menu items', description: 'Contact content/message' })
|
||||||
content!: string;
|
content!: string;
|
||||||
|
|
||||||
|
@IsNotEmpty()
|
||||||
|
@IsEnum(['application', 'restaurant'])
|
||||||
|
@ApiProperty({ description: 'Contact Scope' })
|
||||||
|
scope!: ContactScope;
|
||||||
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsMobilePhone('fa-IR')
|
@IsMobilePhone('fa-IR')
|
||||||
|
|||||||
@@ -38,4 +38,5 @@ export class FindContactsDto {
|
|||||||
@IsEnum(ContactStatusEnum)
|
@IsEnum(ContactStatusEnum)
|
||||||
@ApiPropertyOptional({ enum: ContactStatusEnum, description: 'Filter by status' })
|
@ApiPropertyOptional({ enum: ContactStatusEnum, description: 'Filter by status' })
|
||||||
status?: ContactStatusEnum;
|
status?: ContactStatusEnum;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Entity, Property } from '@mikro-orm/core';
|
import { Entity, Enum, Property } from '@mikro-orm/core';
|
||||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||||
import { ContactStatusEnum } from '../interface/interface';
|
import { ContactScope, ContactStatusEnum } from '../interface/interface';
|
||||||
|
|
||||||
@Entity({ tableName: 'contacts' })
|
@Entity({ tableName: 'contacts' })
|
||||||
export class Contact extends BaseEntity {
|
export class Contact extends BaseEntity {
|
||||||
@@ -13,6 +13,9 @@ export class Contact extends BaseEntity {
|
|||||||
@Property({ nullable: true })
|
@Property({ nullable: true })
|
||||||
phone?: string | null = null;
|
phone?: string | null = null;
|
||||||
|
|
||||||
|
@Enum(() => ContactScope)
|
||||||
|
scope: ContactScope
|
||||||
|
|
||||||
@Property({ default: ContactStatusEnum.New })
|
@Property({ default: ContactStatusEnum.New })
|
||||||
status: ContactStatusEnum = ContactStatusEnum.New;
|
status: ContactStatusEnum = ContactStatusEnum.New;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,3 +2,8 @@ export enum ContactStatusEnum {
|
|||||||
New = 'new',
|
New = 'new',
|
||||||
Seen = 'seen',
|
Seen = 'seen',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ContactScope {
|
||||||
|
New = 'application',
|
||||||
|
Seen = 'restaurant',
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user