Browse Source

chore(api): add missing dto and schema

pull/68/head
isra el 11 months ago
parent
commit
27aaaa7c8a
  1. 49
      api/src/support/dto/create-support-message.dto.ts
  2. 37
      api/src/support/schemas/support-message.schema.ts

49
api/src/support/dto/create-support-message.dto.ts

@ -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
}

37
api/src/support/schemas/support-message.schema.ts

@ -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)
Loading…
Cancel
Save