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
44 changes: 32 additions & 12 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 @@ -140,7 +141,10 @@ type Query {
skill(id: Int!): Skill!
findNotifications(userId: String): [Notification!]!
findOneNotification(id: String!): Notification
findTestimonies(learnerId: String, mentorId: String): [CreateTestimonyOutput!]!
findTestimonies(
learnerId: String
mentorId: String
): [CreateTestimonyOutput!]!
findOneTestimony(id: String!): [CreateTestimonyOutput!]!
}

Expand Down Expand Up @@ -182,22 +186,30 @@ type Mutation {
resetUserPassword(userInput: ResetPasswordInput!): Boolean!
sendResetPassword(email: String!): Boolean!
createAvailability(createAvailabilityInput: CreateAvailabilityInput!): User!
updateAvailability(updateAvailabilityInput: UpdateAvailabilityInput!): Availability!
updateAvailability(
updateAvailabilityInput: UpdateAvailabilityInput!
): Availability!
removeAvailability(id: Int!): Availability!
createEvent(createEventInput: CreateEventInput!): Event!
updateEvent(updateEventInput: UpdateEventInput!): Event!
removeEvent(id: Int!): Event!
createSkill(createSkillInput: CreateSkillInput!): Skill!
updateSkill(updateSkillInput: UpdateSkillInput!): Skill!
removeSkill(id: Int!): Skill!
createNotification(createNotificationInput: CreateNotificationInput!): NotificationData!
updateNotification(updateNotificationInput: UpdateNotificationInput!): NotificationData!
createNotification(
createNotificationInput: CreateNotificationInput!
): NotificationData!
updateNotification(
updateNotificationInput: UpdateNotificationInput!
): NotificationData!
markRead(id: String!): Notification!
removeNotification(id: ID!): Boolean!
createTestimony(createTestimonyInput: CreateTestimonyInput!): Testimony!
updateTestimony(UpdateTestimonyInput: UpdateTestimonyInput!): Testimony!
deleteTestimony(id: Int!): Testimony!
createRecommendation(createRecommendationInput: CreateRecommendationInput!): Recommendation!
createRecommendation(
createRecommendationInput: CreateRecommendationInput!
): Recommendation!
updateApproved(updateApprovedInput: UpdateApprovedInput!): Recommendation!
}

Expand All @@ -207,9 +219,10 @@ input CreateUserInput {
email: String!
password: String!
photoUrl: String
yearsOfExperience: Float
experience: String
skills: [String!]!
birthDate: DateTime
zipCode: String!
country: String!
state: String!
city: String!
Expand All @@ -232,9 +245,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 Expand Up @@ -263,7 +277,9 @@ input SignInUserInput {
rememberMe: Boolean
}

"""The `Upload` scalar type represents a file upload."""
"""
The `Upload` scalar type represents a file upload.
"""
scalar Upload

input ResetPasswordInput {
Expand Down Expand Up @@ -311,12 +327,16 @@ input UpdateEventInput {
}

input CreateSkillInput {
"""Example field (placeholder)"""
"""
Example field (placeholder)
"""
exampleField: Int!
}

input UpdateSkillInput {
"""Example field (placeholder)"""
"""
Example field (placeholder)
"""
exampleField: Int
id: Int!
}
Expand Down Expand Up @@ -361,4 +381,4 @@ input CreateRecommendationInput {
input UpdateApprovedInput {
id: String!
approved: Boolean!
}
}
16 changes: 15 additions & 1 deletion src/modules/user/dto/create-user.input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export class CreateUserInput {

@Field({ nullable: true })
@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