|
|
@ -1,13 +1,13 @@
|
|
|
|
import crypto, { randomUUID } from "crypto";
|
|
|
|
import crypto, { randomUUID } from 'crypto';
|
|
|
|
import { z } from "zod";
|
|
|
|
import { z } from 'zod';
|
|
|
|
import { Prisma } from "@prisma/client";
|
|
|
|
import { Prisma } from '@prisma/client';
|
|
|
|
|
|
|
|
|
|
|
|
import { createRouter } from "./context";
|
|
|
|
import { createRouter } from './context';
|
|
|
|
|
|
|
|
|
|
|
|
const valuation = z.object({
|
|
|
|
const valuation = z.object({
|
|
|
|
currency: z.string(),
|
|
|
|
currency: z.string(),
|
|
|
|
value: z.number(),
|
|
|
|
value: z.number(),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: handle both full time and intern
|
|
|
|
// TODO: handle both full time and intern
|
|
|
|
const offer = z.object({
|
|
|
|
const offer = z.object({
|
|
|
@ -29,7 +29,7 @@ const offer = z.object({
|
|
|
|
location: z.string(),
|
|
|
|
location: z.string(),
|
|
|
|
monthYearReceived: z.date(),
|
|
|
|
monthYearReceived: z.date(),
|
|
|
|
negotiationStrategy: z.string(),
|
|
|
|
negotiationStrategy: z.string(),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const experience = z.object({
|
|
|
|
const experience = z.object({
|
|
|
|
companyId: z.string().optional(),
|
|
|
|
companyId: z.string().optional(),
|
|
|
@ -40,7 +40,7 @@ const experience = z.object({
|
|
|
|
specialization: z.string().optional(),
|
|
|
|
specialization: z.string().optional(),
|
|
|
|
title: z.string().optional(),
|
|
|
|
title: z.string().optional(),
|
|
|
|
totalCompensation: valuation.optional(),
|
|
|
|
totalCompensation: valuation.optional(),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const education = z.object({
|
|
|
|
const education = z.object({
|
|
|
|
endDate: z.date().optional(),
|
|
|
|
endDate: z.date().optional(),
|
|
|
@ -48,7 +48,7 @@ const education = z.object({
|
|
|
|
school: z.string().optional(),
|
|
|
|
school: z.string().optional(),
|
|
|
|
startDate: z.date().optional(),
|
|
|
|
startDate: z.date().optional(),
|
|
|
|
type: z.string().optional(),
|
|
|
|
type: z.string().optional(),
|
|
|
|
})
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
export const offersProfileRouter = createRouter()
|
|
|
|
export const offersProfileRouter = createRouter()
|
|
|
|
.query('listOne', {
|
|
|
|
.query('listOne', {
|
|
|
@ -65,17 +65,17 @@ export const offersProfileRouter = createRouter()
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
company: true,
|
|
|
|
company: true,
|
|
|
|
monthlySalary: true,
|
|
|
|
monthlySalary: true,
|
|
|
|
totalCompensation: true
|
|
|
|
totalCompensation: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
specificYoes: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
specificYoes: true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
discussion: {
|
|
|
|
discussion: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
replies: true,
|
|
|
|
replies: true,
|
|
|
|
replyingTo: true
|
|
|
|
replyingTo: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
offers: {
|
|
|
|
offers: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
@ -84,70 +84,71 @@ export const offersProfileRouter = createRouter()
|
|
|
|
baseSalary: true,
|
|
|
|
baseSalary: true,
|
|
|
|
bonus: true,
|
|
|
|
bonus: true,
|
|
|
|
stocks: true,
|
|
|
|
stocks: true,
|
|
|
|
totalCompensation: true
|
|
|
|
totalCompensation: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
OffersIntern: {
|
|
|
|
OffersIntern: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
monthlySalary: true
|
|
|
|
monthlySalary: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
company: true,
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
company: true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
where: {
|
|
|
|
id: input.profileId
|
|
|
|
id: input.profileId,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.mutation(
|
|
|
|
.mutation('create', {
|
|
|
|
'create',
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
input: z.object({
|
|
|
|
input: z.object({
|
|
|
|
background: z.object({
|
|
|
|
background: z.object({
|
|
|
|
educations: z.array(education),
|
|
|
|
educations: z.array(education),
|
|
|
|
experiences: z.array(experience),
|
|
|
|
experiences: z.array(experience),
|
|
|
|
specificYoes: z.array(z.object({
|
|
|
|
specificYoes: z.array(
|
|
|
|
|
|
|
|
z.object({
|
|
|
|
domain: z.string(),
|
|
|
|
domain: z.string(),
|
|
|
|
yoe: z.number(),
|
|
|
|
yoe: z.number(),
|
|
|
|
})),
|
|
|
|
}),
|
|
|
|
|
|
|
|
),
|
|
|
|
totalYoe: z.number().optional(),
|
|
|
|
totalYoe: z.number().optional(),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
offers: z.array(offer)
|
|
|
|
offers: z.array(offer),
|
|
|
|
}),
|
|
|
|
}),
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: add more
|
|
|
|
// TODO: add more
|
|
|
|
const token = crypto
|
|
|
|
const token = crypto
|
|
|
|
.createHash("sha256")
|
|
|
|
.createHash('sha256')
|
|
|
|
.update(Date.now().toString())
|
|
|
|
.update(Date.now().toString())
|
|
|
|
.digest("hex");
|
|
|
|
.digest('hex');
|
|
|
|
|
|
|
|
|
|
|
|
const profile = await ctx.prisma.offersProfile.create({
|
|
|
|
const profile = await ctx.prisma.offersProfile.create({
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
background: {
|
|
|
|
background: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
educations: {
|
|
|
|
educations: {
|
|
|
|
create:
|
|
|
|
create: input.background.educations.map((x) => ({
|
|
|
|
input.background.educations.map((x) => ({
|
|
|
|
|
|
|
|
endDate: x.endDate,
|
|
|
|
endDate: x.endDate,
|
|
|
|
field: x.field,
|
|
|
|
field: x.field,
|
|
|
|
school: x.school,
|
|
|
|
school: x.school,
|
|
|
|
startDate: x.startDate,
|
|
|
|
startDate: x.startDate,
|
|
|
|
type: x.type
|
|
|
|
type: x.type,
|
|
|
|
}))
|
|
|
|
})),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
experiences: {
|
|
|
|
experiences: {
|
|
|
|
create:
|
|
|
|
create: input.background.experiences.map((x) => {
|
|
|
|
input.background.experiences.map((x) => {
|
|
|
|
if (
|
|
|
|
if (x.jobType === "FULLTIME" && x.totalCompensation?.currency !== undefined && x.totalCompensation.value !== undefined) {
|
|
|
|
x.jobType === 'FULLTIME' &&
|
|
|
|
|
|
|
|
x.totalCompensation?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.totalCompensation.value !== undefined
|
|
|
|
|
|
|
|
) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
company: {
|
|
|
|
company: {
|
|
|
|
connect: {
|
|
|
|
connect: {
|
|
|
|
id: x.companyId
|
|
|
|
id: x.companyId,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
durationInMonths: x.durationInMonths,
|
|
|
|
durationInMonths: x.durationInMonths,
|
|
|
|
jobType: x.jobType,
|
|
|
|
jobType: x.jobType,
|
|
|
@ -158,51 +159,58 @@ export const offersProfileRouter = createRouter()
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.totalCompensation?.currency,
|
|
|
|
currency: x.totalCompensation?.currency,
|
|
|
|
value: x.totalCompensation?.value,
|
|
|
|
value: x.totalCompensation?.value,
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (
|
|
|
|
if (x.jobType === "INTERN" && x.monthlySalary?.currency !== undefined && x.monthlySalary.value !== undefined) {
|
|
|
|
x.jobType === 'INTERN' &&
|
|
|
|
|
|
|
|
x.monthlySalary?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.monthlySalary.value !== undefined
|
|
|
|
|
|
|
|
) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
company: {
|
|
|
|
company: {
|
|
|
|
connect: {
|
|
|
|
connect: {
|
|
|
|
id: x.companyId
|
|
|
|
id: x.companyId,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
durationInMonths: x.durationInMonths,
|
|
|
|
durationInMonths: x.durationInMonths,
|
|
|
|
jobType: x.jobType,
|
|
|
|
jobType: x.jobType,
|
|
|
|
monthlySalary: {
|
|
|
|
monthlySalary: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.monthlySalary?.currency,
|
|
|
|
currency: x.monthlySalary?.currency,
|
|
|
|
value: x.monthlySalary?.value
|
|
|
|
value: x.monthlySalary?.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
specialization: x.specialization,
|
|
|
|
specialization: x.specialization,
|
|
|
|
title: x.title,
|
|
|
|
title: x.title,
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw Prisma.PrismaClientKnownRequestError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
throw Prisma.PrismaClientKnownRequestError;
|
|
|
|
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
specificYoes: {
|
|
|
|
specificYoes: {
|
|
|
|
create:
|
|
|
|
create: input.background.specificYoes.map((x) => {
|
|
|
|
input.background.specificYoes.map((x) => {
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
domain: x.domain,
|
|
|
|
domain: x.domain,
|
|
|
|
yoe: x.yoe
|
|
|
|
yoe: x.yoe,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
totalYoe: input.background.totalYoe,
|
|
|
|
totalYoe: input.background.totalYoe,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
editToken: token,
|
|
|
|
editToken: token,
|
|
|
|
offers: {
|
|
|
|
offers: {
|
|
|
|
create:
|
|
|
|
create: input.offers.map((x) => {
|
|
|
|
input.offers.map((x) => {
|
|
|
|
if (
|
|
|
|
if (x.jobType === "INTERN" && x.job.internshipCycle !== undefined && x.job.monthlySalary?.currency !== undefined && x.job.monthlySalary.value !== undefined && x.job.startYear !== undefined) {
|
|
|
|
x.jobType === 'INTERN' &&
|
|
|
|
|
|
|
|
x.job.internshipCycle !== undefined &&
|
|
|
|
|
|
|
|
x.job.monthlySalary?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.job.monthlySalary.value !== undefined &&
|
|
|
|
|
|
|
|
x.job.startYear !== undefined
|
|
|
|
|
|
|
|
) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
OffersIntern: {
|
|
|
|
OffersIntern: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
@ -210,41 +218,52 @@ export const offersProfileRouter = createRouter()
|
|
|
|
monthlySalary: {
|
|
|
|
monthlySalary: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.job.monthlySalary?.currency,
|
|
|
|
currency: x.job.monthlySalary?.currency,
|
|
|
|
value: x.job.monthlySalary?.value
|
|
|
|
value: x.job.monthlySalary?.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
specialization: x.job.specialization,
|
|
|
|
specialization: x.job.specialization,
|
|
|
|
startYear: x.job.startYear,
|
|
|
|
startYear: x.job.startYear,
|
|
|
|
title: x.job.title,
|
|
|
|
title: x.job.title,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
comments: x.comments,
|
|
|
|
comments: x.comments,
|
|
|
|
company: {
|
|
|
|
company: {
|
|
|
|
connect: {
|
|
|
|
connect: {
|
|
|
|
id: x.companyId
|
|
|
|
id: x.companyId,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
jobType: x.jobType,
|
|
|
|
jobType: x.jobType,
|
|
|
|
location: x.location,
|
|
|
|
location: x.location,
|
|
|
|
monthYearReceived: x.monthYearReceived,
|
|
|
|
monthYearReceived: x.monthYearReceived,
|
|
|
|
negotiationStrategy: x.negotiationStrategy
|
|
|
|
negotiationStrategy: x.negotiationStrategy,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (x.jobType === "FULLTIME" && x.job.base?.currency !== undefined && x.job.base?.value !== undefined && x.job.bonus?.currency !== undefined && x.job.bonus?.value !== undefined && x.job.stocks?.currency !== undefined && x.job.stocks?.value !== undefined && x.job.totalCompensation?.currency !== undefined && x.job.totalCompensation?.value !== undefined && x.job.level !== undefined) {
|
|
|
|
if (
|
|
|
|
|
|
|
|
x.jobType === 'FULLTIME' &&
|
|
|
|
|
|
|
|
x.job.base?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.job.base?.value !== undefined &&
|
|
|
|
|
|
|
|
x.job.bonus?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.job.bonus?.value !== undefined &&
|
|
|
|
|
|
|
|
x.job.stocks?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.job.stocks?.value !== undefined &&
|
|
|
|
|
|
|
|
x.job.totalCompensation?.currency !== undefined &&
|
|
|
|
|
|
|
|
x.job.totalCompensation?.value !== undefined &&
|
|
|
|
|
|
|
|
x.job.level !== undefined
|
|
|
|
|
|
|
|
) {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
OffersFullTime: {
|
|
|
|
OffersFullTime: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
baseSalary: {
|
|
|
|
baseSalary: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.job.base?.currency,
|
|
|
|
currency: x.job.base?.currency,
|
|
|
|
value: x.job.base?.value
|
|
|
|
value: x.job.base?.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
bonus: {
|
|
|
|
bonus: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.job.bonus?.currency,
|
|
|
|
currency: x.job.bonus?.currency,
|
|
|
|
value: x.job.bonus?.value
|
|
|
|
value: x.job.bonus?.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
level: x.job.level,
|
|
|
|
level: x.job.level,
|
|
|
|
specialization: x.job.specialization,
|
|
|
|
specialization: x.job.specialization,
|
|
|
@ -252,35 +271,35 @@ export const offersProfileRouter = createRouter()
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.job.stocks?.currency,
|
|
|
|
currency: x.job.stocks?.currency,
|
|
|
|
value: x.job.stocks?.value,
|
|
|
|
value: x.job.stocks?.value,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
title: x.job.title,
|
|
|
|
title: x.job.title,
|
|
|
|
totalCompensation: {
|
|
|
|
totalCompensation: {
|
|
|
|
create: {
|
|
|
|
create: {
|
|
|
|
currency: x.job.totalCompensation?.currency,
|
|
|
|
currency: x.job.totalCompensation?.currency,
|
|
|
|
value: x.job.totalCompensation?.value,
|
|
|
|
value: x.job.totalCompensation?.value,
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
comments: x.comments,
|
|
|
|
comments: x.comments,
|
|
|
|
company: {
|
|
|
|
company: {
|
|
|
|
connect: {
|
|
|
|
connect: {
|
|
|
|
id: x.companyId
|
|
|
|
id: x.companyId,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
jobType: x.jobType,
|
|
|
|
jobType: x.jobType,
|
|
|
|
location: x.location,
|
|
|
|
location: x.location,
|
|
|
|
monthYearReceived: x.monthYearReceived,
|
|
|
|
monthYearReceived: x.monthYearReceived,
|
|
|
|
negotiationStrategy: x.negotiationStrategy
|
|
|
|
negotiationStrategy: x.negotiationStrategy,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Throw error
|
|
|
|
// Throw error
|
|
|
|
throw Prisma.PrismaClientKnownRequestError
|
|
|
|
throw Prisma.PrismaClientKnownRequestError;
|
|
|
|
})
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
profileName: randomUUID().substring(0,10),
|
|
|
|
profileName: randomUUID().substring(0, 10),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
background: {
|
|
|
|
background: {
|
|
|
@ -290,11 +309,11 @@ export const offersProfileRouter = createRouter()
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
company: true,
|
|
|
|
company: true,
|
|
|
|
monthlySalary: true,
|
|
|
|
monthlySalary: true,
|
|
|
|
totalCompensation: true
|
|
|
|
totalCompensation: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
specificYoes: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
specificYoes: true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
offers: {
|
|
|
|
offers: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
@ -303,21 +322,32 @@ export const offersProfileRouter = createRouter()
|
|
|
|
baseSalary: true,
|
|
|
|
baseSalary: true,
|
|
|
|
bonus: true,
|
|
|
|
bonus: true,
|
|
|
|
stocks: true,
|
|
|
|
stocks: true,
|
|
|
|
totalCompensation: true
|
|
|
|
totalCompensation: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
OffersIntern: {
|
|
|
|
OffersIntern: {
|
|
|
|
include: {
|
|
|
|
include: {
|
|
|
|
monthlySalary: true
|
|
|
|
monthlySalary: true,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: add analysis to profile object then return
|
|
|
|
// TODO: add analysis to profile object then return
|
|
|
|
return profile
|
|
|
|
return profile;
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
})
|
|
|
|
|
|
|
|
.mutation('delete', {
|
|
|
|
|
|
|
|
input: z.object({
|
|
|
|
|
|
|
|
id: z.string(),
|
|
|
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
async resolve({ ctx, input }) {
|
|
|
|
|
|
|
|
return await ctx.prisma.offersProfile.delete({
|
|
|
|
|
|
|
|
where: {
|
|
|
|
|
|
|
|
id: input.id,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|