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

feat: #53 - adding zipcode to user #55

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ADD COLUMN "zip_code" TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "users" ALTER COLUMN "years_of_experience" SET DATA TYPE TEXT;
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
Warnings:

- You are about to drop the column `years_of_experience` on the `users` table. All the data in the column will be lost.

*/
-- AlterTable
ALTER TABLE "users" DROP COLUMN "years_of_experience",
ADD COLUMN "experience" TEXT;
3 changes: 2 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ model User {
facebookId String? @map("facebook_id")
githubId String? @map("github_id")
birthDate DateTime? @map("birth_date")
zipCode String? @map("zip_code")
country String?
state String?
city String?
skills String[]
linkedin String?
github String?
website String?
yearsOfExperience Float? @map("years_of_experience")
experience String? @map("experience")
description String?
jobTitle String? @map("job_title")
jobCompany String? @map("job_company")
Expand Down
9 changes: 6 additions & 3 deletions schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type User {
firstName: String!
lastName: String
photoUrl: String
yearsOfExperience: Float
experience: String
isEmailVerified: Boolean!
isTermsAccepted: Boolean!
onBoardingCompleted: Boolean!
Expand All @@ -54,6 +54,7 @@ type User {
googleId: String
facebookId: String
birthDate: DateTime
zipCode: String
country: String
state: String
city: String
Expand Down Expand Up @@ -224,9 +225,10 @@ input CreateUserInput {
email: String!
password: String!
photoUrl: String
yearsOfExperience: Float
experience: String!
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

precisa ser nullable, remover o !

skills: [String!]!
birthDate: DateTime
zipCode: String!
country: String!
state: String!
city: String!
Expand All @@ -249,9 +251,10 @@ input UpdateUserDto {
email: String
password: String
photoUrl: String
yearsOfExperience: Float
experience: String
skills: [String!]
birthDate: DateTime
zipCode: String
country: String
state: String
city: String
Expand Down
18 changes: 16 additions & 2 deletions src/modules/user/dto/create-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ export class CreateUserInput {
@IsUrl()
photoUrl?: string;

@Field({ nullable: true })
@Field()
@IsOptional()
yearsOfExperience?: number;
@IsString()
@Length(3, 5)
@Matches(/^[0-9]{1,2}-(10|11|[0-9]{1})$/, {
message: 'experience should be on format "99-99" (years-months)',
})
experience?: string;

@Field(() => [String], { nullable: false })
@IsEnum(Skill, { each: true })
Expand All @@ -63,6 +68,15 @@ export class CreateUserInput {
@IsOptional()
birthDate?: Date;

@Field()
@IsOptional()
@IsString()
@Length(9, 9)
@Matches(/^[0-9]{5}-[0-9]{3}/, {
message: 'zipCode should be on format "99999-999"',
})
zipCode?: string;

@Field()
@IsOptional()
@IsString()
Expand Down
6 changes: 4 additions & 2 deletions src/modules/user/entities/user.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ export class User {
lastName?: string | null;
@Field(() => String, { nullable: true })
photoUrl?: string | null;
@Field(() => Float, { nullable: true })
yearsOfExperience?: number | null;
@Field(() => String, { nullable: true })
experience?: string | null;
@Field()
isEmailVerified: boolean;
@Field()
Expand All @@ -39,6 +39,8 @@ export class User {
@Field({ nullable: true })
birthDate?: Date;
@Field({ nullable: true })
zipCode?: string;
@Field({ nullable: true })
country?: string;
@Field({ nullable: true })
state?: string;
Expand Down
2 changes: 1 addition & 1 deletion src/modules/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export class UserService {
user.city,
user.linkedin,
user.github,
user.yearsOfExperience,
user.experience,
user.description,
user.jobTitle,
user.jobCompany,
Expand Down