From 54e297d9c1f68c9876228bd40ac3ac11afa543de Mon Sep 17 00:00:00 2001 From: Stuart Long Chay Boon Date: Mon, 10 Oct 2022 19:32:32 +0800 Subject: [PATCH] [offers][fix] fix merge conflicts --- apps/portal/prisma/schema.prisma | 160 +++++++++++++++++- .../src/pages/offers/testCreateProfile.tsx | 144 ++++++++++++++++ 2 files changed, 297 insertions(+), 7 deletions(-) create mode 100644 apps/portal/src/pages/offers/testCreateProfile.tsx diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 59c53a40..9e4b7c8b 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -58,6 +58,7 @@ model User { questionsAnswerVotes QuestionsAnswerVote[] questionsAnswerComments QuestionsAnswerComment[] questionsAnswerCommentVotes QuestionsAnswerCommentVote[] + OffersProfile OffersProfile[] } enum Vote { @@ -89,13 +90,15 @@ enum TodoStatus { } model Company { - id String @id @default(cuid()) - name String @db.Text - slug String @unique - description String? @db.Text - logoUrl String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) + name String @db.Text + slug String @unique + description String? @db.Text + logoUrl String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + OffersExperience OffersExperience[] + OffersOffer OffersOffer[] } // Start of Resumes project models. @@ -170,6 +173,149 @@ model ResumesCommentVote { // Add Offers project models here, prefix all models with "Offer", // use camelCase for field names, and try to name them consistently // across all models in this file. + +model OffersProfile { + id String @id @default(cuid()) + + background OffersBackground? + + editToken String + + replies OffersReply[] + + offers OffersOffer[] + + user User @relation(fields: [userId], references: [id]) + userId String +} + +model OffersBackground { + id String @id @default(cuid()) + + totalYoe Int? + specificYoes OffersSpecificYoe[] + + experiences OffersExperience[] // For extensibility in the future + + educations OffersEducation[] // For extensibility in the future + + profile OffersProfile @relation(fields: [offersProfileId], references: [id]) + offersProfileId String @unique +} + +model OffersSpecificYoe { + id String @id @default(cuid()) + + yoe Int + domain String + + background OffersBackground @relation(fields: [backgroundId], references: [id]) + backgroundId String +} + +model OffersExperience { + id String @id @default(cuid()) + + company Company? @relation(fields: [companyId], references: [id]) + companyId String? + + jobType JobType? + title String? + currency String? + + // Add more fields + durationInMonths Int? + specialization String? + + // FULLTIME fields + level String? + totalCompensation BigInt? + + // INTERN fields + monthlySalary BigInt? + + background OffersBackground @relation(fields: [backgroundId], references: [id]) + backgroundId String +} + +enum JobType { + INTERN + FULLTIME +} + +model OffersEducation { + id String @id @default(cuid()) + type String? + field String? + attending Boolean? + + // Add more fields + school String? + startDate DateTime? + endDate DateTime? + + background OffersBackground @relation(fields: [backgroundId], references: [id]) + backgroundId String +} + +model OffersReply { + id String @id @default(cuid()) + + message String + upvotes Int // CHECK: Need log in to upvote? + + parentReplyId String? + parentReply OffersReply? @relation("ReplyThread", fields: [parentReplyId], references: [id]) + replies OffersReply[] @relation("ReplyThread") + + profile OffersProfile @relation(fields: [profileId], references: [id]) + profileId String +} + +model OffersOffer { + id String @id @default(cuid()) + + profile OffersProfile @relation(fields: [profileId], references: [id]) + profileId String + + company Company @relation(fields: [companyId], references: [id]) + companyId String + + title String + specialization String + monthYearReceived DateTime + location String + negotiationStrategy String? + comments String? + + jobType JobType + + OffersIntern OffersIntern? + OffersFullTime OffersFullTime? +} + +model OffersIntern { + offerId String @id + offer OffersOffer @relation(fields: [offerId], references: [id]) + + internshipCycle String + startYear Int + monthlySalary BigInt + currency String +} + +model OffersFullTime { + offerId String @id + offer OffersOffer @relation(fields: [offerId], references: [id]) + + level String + totalCompensation BigInt + baseSalary BigInt + bonus BigInt + stocks BigInt // CHECK: What to store stocks as? String or Int + currency String +} + // End of Offers project models. // Start of Questions project models. diff --git a/apps/portal/src/pages/offers/testCreateProfile.tsx b/apps/portal/src/pages/offers/testCreateProfile.tsx new file mode 100644 index 00000000..f58dbfd4 --- /dev/null +++ b/apps/portal/src/pages/offers/testCreateProfile.tsx @@ -0,0 +1,144 @@ +import React, { useState } from 'react'; + +import { trpc } from '~/utils/trpc'; + +function Test() { +// F const data = trpc.useQuery([ +// 'offers.profile.', +// { +// limit: 3, +// location: 'Singapore, Singapore', +// offset: 0, +// yoeCategory: 0, +// }, +// ]); + + const [createdData, setCreatedData] = useState("") + + const createMutation = trpc.useMutation(['offers.profile.create'], { + onError(error: any) { + alert(error) + }, + onSuccess(data) { + setCreatedData(JSON.stringify(data)) + }, + }); + + const handleClick = () => { + createMutation.mutate({ +"background": { + "educations": [ + { + "endDate": new Date("2018-09-30T07:58:54.000Z"), + "field": "Computer Science", + "school": "National University of Singapore", + "startDate": new Date("2014-09-30T07:58:54.000Z"), + "type": "Bachelors" + } + ], + "experiences": [ + { + "companyId": "cl92ly8xm0000w3mwh5ymyqmx", + "durationInMonths": 24, + "jobType": "FULLTIME", + "level": "Junior", + // "monthlySalary": undefined, + "specialization": "Front End", + "title": "Software Engineer", + "totalCompensation": { + "currency": "SGD", + "value": 104100 + } + } + ], + "specificYoes": [ + { + "domain": "Front End", + "yoe": 2 + }, + { + "domain": "Full Stack", + "yoe": 2 + } + ], + "totalYoe": 4 + }, + "offers": [ + { + "comments": "", + "companyId": "cl92ly8xm0000w3mwh5ymyqmx", + "job": { + "base": { + "currency": "SGD", + "value": 84000 + }, + "bonus": { + "currency": "SGD", + "value": 20000 + }, + "level": "Junior", + "specialization": "Front End", + "stocks": { + "currency": "SGD", + "value": 100 + }, + "title": "Software Engineer", + "totalCompensation": { + "currency": "SGD", + "value": 104100 + } + }, + "jobType": "FULLTIME", + "location": "Singapore, Singapore", + "monthYearReceived": new Date("2022-09-30T07:58:54.000Z"), + "negotiationStrategy": "Leveraged having multiple offers" + }, + { + "comments": "", + "companyId": "cl92ly8xm0000w3mwh5ymyqmx", + "job": { + "base": { + "currency": "SGD", + "value": 84000 + }, + "bonus": { + "currency": "SGD", + "value": 20000 + }, + "level": "Junior", + "specialization": "Front End", + "stocks": { + "currency": "SGD", + "value": 100 + }, + "title": "Software Engineer", + "totalCompensation": { + "currency": "SGD", + "value": 104100 + } + }, + "jobType": "FULLTIME", + "location": "Singapore, Singapore", + "monthYearReceived": new Date("2022-09-30T07:58:54.000Z"), + "negotiationStrategy": "Leveraged having multiple offers" + } + ] + }); + }; + + return ( + // + <> +
+ {createdData} +
+ + + ); +} + +export default Test;