172 lines
2.7 KiB
TypeScript
172 lines
2.7 KiB
TypeScript
import { Type } from 'class-transformer';
|
|
import {
|
|
ArrayMinSize,
|
|
IsArray,
|
|
IsBoolean,
|
|
IsInt,
|
|
IsNumber,
|
|
IsOptional,
|
|
IsString,
|
|
MaxLength,
|
|
Min,
|
|
MinLength,
|
|
ValidateIf,
|
|
} from 'class-validator';
|
|
|
|
export class CreateLoyaltyTierDto {
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(80)
|
|
name!: string;
|
|
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(0)
|
|
minPoints!: number;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(32)
|
|
color?: string | null;
|
|
}
|
|
|
|
export class UpdateLoyaltyTierDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(80)
|
|
name?: string;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(0)
|
|
minPoints?: number;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(32)
|
|
color?: string | null;
|
|
}
|
|
|
|
export class AdjustLoyaltyPointsDto {
|
|
@Type(() => Number)
|
|
@IsNumber()
|
|
delta!: number;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(200)
|
|
reason?: string;
|
|
}
|
|
|
|
export class BulkAdjustLoyaltyDto {
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@IsString({ each: true })
|
|
personIds!: string[];
|
|
|
|
@Type(() => Number)
|
|
@IsNumber()
|
|
delta!: number;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(200)
|
|
reason?: string;
|
|
}
|
|
|
|
export class LoyaltyMessageDto {
|
|
@IsArray()
|
|
@ArrayMinSize(1)
|
|
@IsString({ each: true })
|
|
personIds!: string[];
|
|
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(500)
|
|
text!: string;
|
|
}
|
|
|
|
export class UpdateLoyaltySettingsDto {
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
enabled?: boolean;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(0)
|
|
welcomePoints?: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
notifyOnAdjust?: boolean;
|
|
}
|
|
|
|
export class CreateLoyaltyRewardDto {
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(80)
|
|
name!: string;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(240)
|
|
description?: string | null;
|
|
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
pointsCost!: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(32)
|
|
color?: string | null;
|
|
}
|
|
|
|
export class UpdateLoyaltyRewardDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(80)
|
|
name?: string;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(240)
|
|
description?: string | null;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
pointsCost?: number;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
isActive?: boolean;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
@MaxLength(32)
|
|
color?: string | null;
|
|
}
|
|
|
|
export class RedeemLoyaltyRewardDto {
|
|
@IsString()
|
|
@MinLength(1)
|
|
personId!: string;
|
|
}
|