chore(api): add missing dto and schema

This commit is contained in:
isra el
2025-04-04 23:08:32 +03:00
parent 225d00de5b
commit 27aaaa7c8a
2 changed files with 86 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import {
IsEmail,
IsEnum,
IsNotEmpty,
IsOptional,
IsString,
} from 'class-validator'
export enum SupportCategory {
GENERAL = 'general',
TECHNICAL = 'technical',
BILLING_AND_PAYMENTS = 'billing-and-payments',
ACCOUNT_DELETION = 'account-deletion',
OTHER = 'other',
}
export class CreateSupportMessageDto {
@IsOptional()
@IsString()
user?: string
@IsNotEmpty()
@IsString()
name: string
@IsNotEmpty()
@IsEmail()
email: string
@IsOptional()
@IsString()
phone?: string
@IsNotEmpty()
@IsEnum(SupportCategory)
category: SupportCategory
@IsNotEmpty()
@IsString()
message: string
@IsOptional()
@IsString()
ip?: string
@IsOptional()
@IsString()
userAgent?: string
}

View File

@@ -0,0 +1,37 @@
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose'
import { Document, Types } from 'mongoose'
import { User } from 'src/users/schemas/user.schema'
export type SupportMessageDocument = SupportMessage & Document
@Schema({ timestamps: true })
export class SupportMessage {
@Prop({ type: Types.ObjectId, ref: User.name })
user: User
@Prop()
name: string
@Prop()
email: string
@Prop()
phone: string
@Prop()
category: string
@Prop()
message: string
@Prop()
ip: string
@Prop()
userAgent: string
@Prop({ default: 'RECEIVED' })
type: string
}
export const SupportMessageSchema = SchemaFactory.createForClass(SupportMessage)