Skip to content

Commit

Permalink
feat(src) finnish onboarding process
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Pino committed Aug 31, 2024
1 parent 1ef3ec9 commit 13a13c6
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 45 deletions.
32 changes: 19 additions & 13 deletions src/modules/individual-customer/dtos/company-info.dto.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { ApiProperty } from '@nestjs/swagger';
import {
IsString,
Length,
IsPhoneNumber,
IsNumberString,
Length
} from 'class-validator';

export class CompanyInfoDTO {
Expand All @@ -13,52 +11,60 @@ export class CompanyInfoDTO {
})
@IsString()
@Length(1, 100)
name: string;
companyName: string;

@ApiProperty({
description: 'Phone number of the company',
example: '+1-800-123-4567',
})
@IsPhoneNumber(null)
phone: string;
@IsString()
companyPhone: string;

@ApiProperty({
description: 'Address of the company',
example: '456 Business Rd',
})
@IsString()
@Length(1, 200)
address: string;
companyAddress: string;

@ApiProperty({
description: 'State where the company is located',
example: 'New York',
})
@IsString()
@Length(1, 100)
state: string;
companyState: string;

@ApiProperty({
description: 'City where the company is located',
example: 'New York City',
})
@IsString()
@Length(1, 100)
city: string;
companyCity: string;

@ApiProperty({
description: 'Town where the company is located',
example: 'New York Town',
})
@IsString()
@Length(1, 100)
companyTown: string;

@ApiProperty({
description: 'Year the company was founded or the individual joined',
example: '2015',
})
@IsNumberString()
@Length(4, 4)
year: string;
@IsString()
@Length(4, 10)
companyYear: string;

@ApiProperty({
description: 'Month the company was founded or the individual joined',
example: 'March',
})
@IsString()
@Length(1, 50)
month: string;
companyMonth: string;
}
4 changes: 2 additions & 2 deletions src/modules/individual-customer/dtos/contact-info.dto.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsPhoneNumber } from 'class-validator';
import { IsString } from 'class-validator';

export class ContactInfoDTO {
@ApiProperty({
description: 'Phone number of the individual customer',
example: '+1-555-555-5555',
})
@IsPhoneNumber(null)
@IsString(null)
phone: string;
}
6 changes: 3 additions & 3 deletions src/modules/individual-customer/dtos/education-data.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ export class EducationDataDTO {
})
@IsString()
@Length(1, 100)
level: string;
educationLevel: string;

@ApiProperty({
description: 'Area of specialization',
example: 'Computer Science',
})
@IsString()
@Length(1, 100)
area: string;
educationArea: string;

@ApiProperty({
description: 'Year of graduation or last year attended',
example: '2015',
})
@IsNumberString()
@Length(4, 4)
year: string;
educationYear: string;
}
12 changes: 6 additions & 6 deletions src/modules/individual-customer/dtos/housing-data.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ApiProperty } from '@nestjs/swagger';
import { IsString, Length, IsNumberString } from 'class-validator';
import { IsString, Length } from 'class-validator';

export class HousingDataDTO {
@ApiProperty({
Expand All @@ -8,21 +8,21 @@ export class HousingDataDTO {
})
@IsString()
@Length(1, 100)
type: string;
housingType: string;

@ApiProperty({
description: 'Year of purchase or construction',
example: '2010',
})
@IsNumberString()
@Length(4, 4)
year: string;
@IsString()
@Length(4, 50)
housingYear: string;

@ApiProperty({
description: 'Month of purchase or construction',
example: 'June',
})
@IsString()
@Length(1, 50)
month: string;
housingMonth: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export class IndividualCustomer {
@Column({ type: 'varchar', length: 100, nullable: true })
housingType: string;

@Column({ type: 'varchar', length: 4, nullable: true })
@Column({ type: 'varchar', length: 50, nullable: true })
housingYear: string;

@Column({ type: 'varchar', length: 2, nullable: true })
@Column({ type: 'varchar', length: 50, nullable: true })
housingMonth: string;

@Column({ type: 'varchar', length: 100, nullable: true })
Expand All @@ -86,22 +86,25 @@ export class IndividualCustomer {
@Column({ type: 'varchar', length: 100, nullable: true })
companyName: string;

@Column({ type: 'varchar', length: 15, nullable: true })
@Column({ type: 'varchar', length: 30, nullable: true })
companyPhone: string;

@Column({ type: 'varchar', length: 200, nullable: true })
companyAddress: string;

@Column({ type: 'varchar', length: 100, nullable: true })
companyState: string;

@Column({ type: 'varchar', length: 100, nullable: true })
companyCity: string;

@Column({ type: 'varchar', length: 100, nullable: true })
companyState: string;
companyTown: string;

@Column({ type: 'varchar', length: 4, nullable: true })
@Column({ type: 'varchar', length: 20, nullable: true })
companyYear: string;

@Column({ type: 'varchar', length: 2, nullable: true })
@Column({ type: 'varchar', length: 30, nullable: true })
companyMonth: string;

@Column({ type: 'varchar', length: 15, nullable: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ export enum StatusOnboarding {
OCCUPATION = 'OCCUPATION',
COMPANY = 'COMPANY',
CONTACT = 'CONTACT',
COMPLETE = 'COMPLETE'
COMPLETED = 'COMPLETED',
}
29 changes: 15 additions & 14 deletions src/modules/individual-customer/individual-customer.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ export class IndividualCustomerService extends CrudService<IndividualCustomer> {
housingDataDTO: HousingDataDTO,
): Promise<IndividualCustomer> {
const individualCustomer = await this.findCustomerById(id);
individualCustomer.housingType = housingDataDTO.type;
individualCustomer.housingYear = housingDataDTO.year;
individualCustomer.housingMonth = housingDataDTO.month;
individualCustomer.housingType = housingDataDTO.housingType;
individualCustomer.housingYear = housingDataDTO.housingYear;
individualCustomer.housingMonth = housingDataDTO.housingMonth;
individualCustomer.status = StatusOnboarding.EDUCATION;

return this.individualCustomerRepository.save(individualCustomer);
Expand All @@ -78,9 +78,9 @@ export class IndividualCustomerService extends CrudService<IndividualCustomer> {
educationDataDTO: EducationDataDTO,
): Promise<IndividualCustomer> {
const individualCustomer = await this.findCustomerById(id);
individualCustomer.educationLevel = educationDataDTO.level;
individualCustomer.educationArea = educationDataDTO.area;
individualCustomer.educationYear = educationDataDTO.year;
individualCustomer.educationLevel = educationDataDTO.educationLevel;
individualCustomer.educationArea = educationDataDTO.educationArea;
individualCustomer.educationYear = educationDataDTO.educationYear;
individualCustomer.status = StatusOnboarding.OCCUPATION;

return this.individualCustomerRepository.save(individualCustomer);
Expand All @@ -103,13 +103,14 @@ export class IndividualCustomerService extends CrudService<IndividualCustomer> {
companyInfoDTO: CompanyInfoDTO,
): Promise<IndividualCustomer> {
const individualCustomer = await this.findCustomerById(id);
individualCustomer.companyName = companyInfoDTO.name;
individualCustomer.companyPhone = companyInfoDTO.phone;
individualCustomer.companyAddress = companyInfoDTO.address;
individualCustomer.companyState = companyInfoDTO.state;
individualCustomer.companyCity = companyInfoDTO.city;
individualCustomer.companyYear = companyInfoDTO.year;
individualCustomer.companyMonth = companyInfoDTO.month;
individualCustomer.companyName = companyInfoDTO.companyName;
individualCustomer.companyPhone = companyInfoDTO.companyPhone;
individualCustomer.companyAddress = companyInfoDTO.companyAddress;
individualCustomer.companyState = companyInfoDTO.companyState;
individualCustomer.companyCity = companyInfoDTO.companyCity;
individualCustomer.companyTown = companyInfoDTO.companyTown;
individualCustomer.companyYear = companyInfoDTO.companyYear;
individualCustomer.companyMonth = companyInfoDTO.companyMonth;
individualCustomer.status = StatusOnboarding.CONTACT;

return this.individualCustomerRepository.save(individualCustomer);
Expand All @@ -121,7 +122,7 @@ export class IndividualCustomerService extends CrudService<IndividualCustomer> {
): Promise<IndividualCustomer> {
const individualCustomer = await this.findCustomerById(id);
individualCustomer.phone = contactInfoDTO.phone;
individualCustomer.status = StatusOnboarding.COMPLETE;
individualCustomer.status = StatusOnboarding.COMPLETED;

return this.individualCustomerRepository.save(individualCustomer);
}
Expand Down

0 comments on commit 13a13c6

Please sign in to comment.