2026-09-11 01:09:59 +03:30
|
|
|
import { Type } from 'class-transformer';
|
2026-08-29 21:06:30 +03:30
|
|
|
import {
|
|
|
|
|
IsIn,
|
2026-09-11 01:09:59 +03:30
|
|
|
IsNumber,
|
2026-08-29 21:06:30 +03:30
|
|
|
IsString,
|
2026-09-14 19:19:09 +03:30
|
|
|
Matches,
|
2026-09-11 01:09:59 +03:30
|
|
|
Max,
|
2026-08-29 21:06:30 +03:30
|
|
|
MaxLength,
|
2026-09-11 01:09:59 +03:30
|
|
|
Min,
|
2026-08-29 21:06:30 +03:30
|
|
|
MinLength,
|
|
|
|
|
} from 'class-validator';
|
|
|
|
|
|
|
|
|
|
const INVITE_ROLES = ['admin', 'sales', 'support'] as const;
|
|
|
|
|
const ALL_ROLES = ['owner', 'admin', 'sales', 'support'] as const;
|
|
|
|
|
|
|
|
|
|
export class InviteUserDto {
|
2026-09-14 19:19:09 +03:30
|
|
|
@IsString()
|
|
|
|
|
@Matches(/^09\d{9}$|^\+98\d{10}$|^98\d{10}$|^9\d{9}$/, {
|
|
|
|
|
message: 'شماره موبایل معتبر نیست',
|
|
|
|
|
})
|
|
|
|
|
mobile!: string;
|
2026-08-29 21:06:30 +03:30
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(2)
|
|
|
|
|
@MaxLength(120)
|
|
|
|
|
fullName!: string;
|
|
|
|
|
|
|
|
|
|
@IsString()
|
|
|
|
|
@MinLength(8)
|
|
|
|
|
@MaxLength(72)
|
|
|
|
|
password!: string;
|
|
|
|
|
|
|
|
|
|
@IsIn(INVITE_ROLES)
|
|
|
|
|
role!: (typeof INVITE_ROLES)[number];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export class UpdateUserRoleDto {
|
|
|
|
|
@IsIn(ALL_ROLES)
|
|
|
|
|
role!: (typeof ALL_ROLES)[number];
|
|
|
|
|
}
|
2026-09-11 01:09:59 +03:30
|
|
|
|
|
|
|
|
export class UpdateUserCommissionDto {
|
|
|
|
|
@Type(() => Number)
|
|
|
|
|
@IsNumber()
|
|
|
|
|
@Min(0)
|
|
|
|
|
@Max(100)
|
|
|
|
|
commissionPercent!: number;
|
|
|
|
|
}
|