From 5d3c68ba85770edeb6759bec14f8b3c991c3110b Mon Sep 17 00:00:00 2001 From: Ederson Date: Fri, 15 Nov 2024 11:23:58 -0400 Subject: [PATCH] Add phone and email to the account setting section --- .../20241013140617-add-email-to-workspaces.js | 17 +++++++++++++++++ .../gateway/dto/initialize-workspace.dto.ts | 10 +++++++++- .../attributes/workspace.attributes.ts | 1 + .../workspaces/domains/workspaces.domain.ts | 4 ++++ .../dto/edit-workspace-details-dto.ts | 16 +++++++++++++++- .../workspaces/models/workspace.model.ts | 3 +++ 6 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 migrations/20241013140617-add-email-to-workspaces.js diff --git a/migrations/20241013140617-add-email-to-workspaces.js b/migrations/20241013140617-add-email-to-workspaces.js new file mode 100644 index 00000000..fd4eb2a8 --- /dev/null +++ b/migrations/20241013140617-add-email-to-workspaces.js @@ -0,0 +1,17 @@ +'use strict'; + +const tableName = 'workspaces'; +const newColumn = 'email'; + +module.exports = { + async up(queryInterface, Sequelize) { + await queryInterface.addColumn(tableName, newColumn, { + type: Sequelize.STRING, + allowNull: true, + }); + }, + + async down(queryInterface) { + await queryInterface.removeColumn(tableName, newColumn); + }, +}; diff --git a/src/modules/gateway/dto/initialize-workspace.dto.ts b/src/modules/gateway/dto/initialize-workspace.dto.ts index f54fbc1d..3bcc657c 100644 --- a/src/modules/gateway/dto/initialize-workspace.dto.ts +++ b/src/modules/gateway/dto/initialize-workspace.dto.ts @@ -1,5 +1,5 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsNotEmpty, IsNumber, IsOptional } from 'class-validator'; +import { IsEmail, IsNotEmpty, IsNumber, IsOptional } from 'class-validator'; export class InitializeWorkspaceDto { @ApiProperty({ @@ -23,6 +23,14 @@ export class InitializeWorkspaceDto { @IsOptional() phoneNumber?: string; + @ApiProperty({ + example: 'hello@internxt.com', + description: 'Email', + }) + @IsOptional() + @IsEmail() + email?: string; + @ApiProperty({ example: 312321312, description: 'Workspace max space in bytes', diff --git a/src/modules/workspaces/attributes/workspace.attributes.ts b/src/modules/workspaces/attributes/workspace.attributes.ts index 7e722654..9f900305 100644 --- a/src/modules/workspaces/attributes/workspace.attributes.ts +++ b/src/modules/workspaces/attributes/workspace.attributes.ts @@ -10,6 +10,7 @@ export interface WorkspaceAttributes { setupCompleted: boolean; numberOfSeats: number; phoneNumber?: string; + email?: string; rootFolderId?: string; createdAt: Date; updatedAt: Date; diff --git a/src/modules/workspaces/domains/workspaces.domain.ts b/src/modules/workspaces/domains/workspaces.domain.ts index 1683a8b8..d0ff463d 100644 --- a/src/modules/workspaces/domains/workspaces.domain.ts +++ b/src/modules/workspaces/domains/workspaces.domain.ts @@ -15,6 +15,7 @@ export class Workspace implements WorkspaceAttributes { setupCompleted: boolean; numberOfSeats: number; phoneNumber?: string; + email?: string; createdAt: Date; updatedAt: Date; @@ -31,6 +32,7 @@ export class Workspace implements WorkspaceAttributes { avatar, numberOfSeats, phoneNumber, + email, createdAt, updatedAt, }: WorkspaceAttributes) { @@ -46,6 +48,7 @@ export class Workspace implements WorkspaceAttributes { this.rootFolderId = rootFolderId; this.numberOfSeats = numberOfSeats; this.phoneNumber = phoneNumber; + this.email = email; this.createdAt = createdAt; this.updatedAt = updatedAt; } @@ -83,6 +86,7 @@ export class Workspace implements WorkspaceAttributes { workspaceUserId: this.workspaceUserId, numberOfSeats: this.numberOfSeats, phoneNumber: this.phoneNumber, + email: this.email, setupCompleted: this.setupCompleted, createdAt: this.createdAt, updatedAt: this.updatedAt, diff --git a/src/modules/workspaces/dto/edit-workspace-details-dto.ts b/src/modules/workspaces/dto/edit-workspace-details-dto.ts index b8f5239b..b4f9d1bc 100644 --- a/src/modules/workspaces/dto/edit-workspace-details-dto.ts +++ b/src/modules/workspaces/dto/edit-workspace-details-dto.ts @@ -1,5 +1,11 @@ import { ApiProperty } from '@nestjs/swagger'; -import { IsOptional, IsPhoneNumber, IsString, Length } from 'class-validator'; +import { + IsOptional, + IsPhoneNumber, + IsString, + Length, + IsEmail, +} from 'class-validator'; import { Workspace } from '../domains/workspaces.domain'; export class EditWorkspaceDetailsDto { @@ -34,4 +40,12 @@ export class EditWorkspaceDetailsDto { @IsOptional() @IsPhoneNumber() phoneNumber?: Workspace['phoneNumber']; + + @ApiProperty({ + example: 'hello@internxt.com', + description: 'Email', + }) + @IsOptional() + @IsEmail() + email?: Workspace['email']; } diff --git a/src/modules/workspaces/models/workspace.model.ts b/src/modules/workspaces/models/workspace.model.ts index 8f9158d8..d27d78b6 100644 --- a/src/modules/workspaces/models/workspace.model.ts +++ b/src/modules/workspaces/models/workspace.model.ts @@ -67,6 +67,9 @@ export class WorkspaceModel extends Model implements WorkspaceAttributes { @Column(DataType.STRING) phoneNumber: string; + @Column(DataType.STRING) + email: string; + @HasOne(() => FolderModel, 'uuid') rootFolder: FolderModel;