200 lines
3.7 KiB
TypeScript
200 lines
3.7 KiB
TypeScript
import { Type } from 'class-transformer';
|
|
import {
|
|
IsBoolean,
|
|
IsDateString,
|
|
IsIn,
|
|
IsInt,
|
|
IsOptional,
|
|
IsString,
|
|
Max,
|
|
MaxLength,
|
|
Min,
|
|
MinLength,
|
|
ValidateIf,
|
|
} from 'class-validator';
|
|
|
|
const ACTIVITY_TYPES = ['call', 'meeting', 'task', 'note'] as const;
|
|
const ACTIVITY_STATUSES = ['open', 'done', 'canceled'] as const;
|
|
const ACTIVITY_PRIORITIES = ['very_low', 'low', 'medium', 'high', 'very_high'] as const;
|
|
const ACTIVITY_FILTERS = ['today', 'overdue', 'upcoming', 'done', 'all'] as const;
|
|
|
|
export class ListActivitiesQueryDto {
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_FILTERS)
|
|
filter?: (typeof ACTIVITY_FILTERS)[number] = 'today';
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
q?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
personId?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
companyId?: string;
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
dealId?: string;
|
|
|
|
/** Inclusive start (ISO). When set with/without filter, restricts dueAt. */
|
|
@IsOptional()
|
|
@IsDateString()
|
|
from?: string;
|
|
|
|
/** Exclusive end (ISO). */
|
|
@IsOptional()
|
|
@IsDateString()
|
|
to?: string;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
page?: number = 1;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(200)
|
|
limit?: number = 50;
|
|
}
|
|
|
|
export class CreateActivityDto {
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(200)
|
|
title!: string;
|
|
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_TYPES)
|
|
type?: (typeof ACTIVITY_TYPES)[number];
|
|
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_PRIORITIES)
|
|
priority?: (typeof ACTIVITY_PRIORITIES)[number];
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(2000)
|
|
description?: string;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsDateString()
|
|
dueAt?: string | null;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(24 * 60)
|
|
durationMinutes?: number | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsDateString()
|
|
reminderAt?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
reminderNotifyApp?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
reminderNotifySms?: boolean;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
personId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
companyId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
dealId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
assigneeId?: string | null;
|
|
}
|
|
|
|
export class UpdateActivityDto {
|
|
@IsOptional()
|
|
@IsString()
|
|
@MinLength(2)
|
|
@MaxLength(200)
|
|
title?: string;
|
|
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_TYPES)
|
|
type?: (typeof ACTIVITY_TYPES)[number];
|
|
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_STATUSES)
|
|
status?: (typeof ACTIVITY_STATUSES)[number];
|
|
|
|
@IsOptional()
|
|
@IsIn(ACTIVITY_PRIORITIES)
|
|
priority?: (typeof ACTIVITY_PRIORITIES)[number];
|
|
|
|
@IsOptional()
|
|
@IsString()
|
|
@MaxLength(2000)
|
|
description?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsDateString()
|
|
dueAt?: string | null;
|
|
|
|
@IsOptional()
|
|
@Type(() => Number)
|
|
@IsInt()
|
|
@Min(1)
|
|
@Max(24 * 60)
|
|
durationMinutes?: number | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsDateString()
|
|
reminderAt?: string | null;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
reminderNotifyApp?: boolean;
|
|
|
|
@IsOptional()
|
|
@IsBoolean()
|
|
reminderNotifySms?: boolean;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
personId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
companyId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
dealId?: string | null;
|
|
|
|
@IsOptional()
|
|
@ValidateIf((_, v) => v !== '' && v != null)
|
|
@IsString()
|
|
assigneeId?: string | null;
|
|
}
|