Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-2386] Add phone and email to the account setting section #430

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions migrations/20241013140617-add-email-to-workspaces.js
Original file line number Diff line number Diff line change
@@ -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);
},
};
10 changes: 9 additions & 1 deletion src/modules/gateway/dto/initialize-workspace.dto.ts
Original file line number Diff line number Diff line change
@@ -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({
Expand All @@ -23,6 +23,14 @@ export class InitializeWorkspaceDto {
@IsOptional()
phoneNumber?: string;

@ApiProperty({
example: '[email protected]',
description: 'Email',
})
@IsOptional()
@IsEmail()
email?: string;

@ApiProperty({
example: 312321312,
description: 'Workspace max space in bytes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface WorkspaceAttributes {
setupCompleted: boolean;
numberOfSeats: number;
phoneNumber?: string;
email?: string;
rootFolderId?: string;
createdAt: Date;
updatedAt: Date;
Expand Down
4 changes: 4 additions & 0 deletions src/modules/workspaces/domains/workspaces.domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export class Workspace implements WorkspaceAttributes {
setupCompleted: boolean;
numberOfSeats: number;
phoneNumber?: string;
email?: string;
createdAt: Date;
updatedAt: Date;

Expand All @@ -31,6 +32,7 @@ export class Workspace implements WorkspaceAttributes {
avatar,
numberOfSeats,
phoneNumber,
email,
createdAt,
updatedAt,
}: WorkspaceAttributes) {
Expand All @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down
16 changes: 15 additions & 1 deletion src/modules/workspaces/dto/edit-workspace-details-dto.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -34,4 +40,12 @@ export class EditWorkspaceDetailsDto {
@IsOptional()
@IsPhoneNumber()
phoneNumber?: Workspace['phoneNumber'];

@ApiProperty({
example: '[email protected]',
description: 'Email',
})
@IsOptional()
@IsEmail()
email?: Workspace['email'];
}
3 changes: 3 additions & 0 deletions src/modules/workspaces/models/workspace.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Loading