mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2026-03-10 18:31:46 +00:00
- Introduced optional timezone fields in User and Device entities to store user preferences and device timezones. - Updated request DTOs for login and user updates to include timezone information. - Enhanced AuthService to handle timezone during device registration and updates. - Added migration to incorporate timezone fields in the database schema.
46 lines
2.0 KiB
TypeScript
46 lines
2.0 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { IsDateString, IsEmail, IsEnum, IsNotEmpty, IsOptional, IsString, IsUUID } from 'class-validator';
|
|
import { i18nValidationMessage as i18n } from 'nestjs-i18n';
|
|
import { Gender } from '~/customer/enums';
|
|
export class UpdateUserRequestDto {
|
|
@ApiProperty({ example: 'John' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'user.firstName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'user.firstName' }) })
|
|
@IsOptional()
|
|
firstName!: string;
|
|
|
|
@ApiProperty({ example: 'Doe' })
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'user.lastName' }) })
|
|
@IsNotEmpty({ message: i18n('validation.IsNotEmpty', { path: 'general', property: 'user.lastName' }) })
|
|
@IsOptional()
|
|
lastName!: string;
|
|
|
|
@ApiPropertyOptional({ example: 'child@example.com' })
|
|
@IsEmail({}, { message: i18n('validation.IsEmail', { path: 'general', property: 'user.email' }) })
|
|
@IsOptional()
|
|
email!: string;
|
|
|
|
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
|
|
@IsUUID('4', { message: i18n('validation.IsUUID', { path: 'general', property: 'user.profilePictureId' }) })
|
|
@IsOptional()
|
|
profilePictureId!: string;
|
|
|
|
@ApiPropertyOptional({ enum: Gender })
|
|
@IsEnum(Gender, { message: i18n('validation.IsEnum', { path: 'general', property: 'customer.gender' }) })
|
|
@IsOptional()
|
|
gender!: Gender;
|
|
|
|
@ApiPropertyOptional({ example: '2020-01-01' })
|
|
@IsDateString({}, { message: i18n('validation.IsDateString', { path: 'general', property: 'customer.dateOfBirth' }) })
|
|
@IsOptional()
|
|
dateOfBirth!: Date;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'Asia/Riyadh',
|
|
description: 'User preferred timezone for reports/statements (e.g., "Asia/Riyadh", "America/New_York"). Leave empty or "Auto" to use device timezone.',
|
|
})
|
|
@IsOptional()
|
|
@IsString({ message: i18n('validation.IsString', { path: 'general', property: 'user.timezone' }) })
|
|
timezone?: string;
|
|
}
|