@ -27,7 +27,15 @@ const company = z.object({
} ) ;
const offer = z . object ( {
OffersFullTime : z
comments : z.string ( ) ,
company : company.nullish ( ) ,
companyId : z.string ( ) ,
id : z.string ( ) . optional ( ) ,
jobType : z.string ( ) ,
location : z.string ( ) ,
monthYearReceived : z.date ( ) ,
negotiationStrategy : z.string ( ) ,
offersFullTime : z
. object ( {
baseSalary : valuation.nullish ( ) ,
baseSalaryId : z.string ( ) . nullish ( ) ,
@ -43,7 +51,8 @@ const offer = z.object({
totalCompensationId : z.string ( ) . nullish ( ) ,
} )
. nullish ( ) ,
OffersIntern : z
offersFullTimeId : z.string ( ) . nullish ( ) ,
offersIntern : z
. object ( {
id : z.string ( ) . optional ( ) ,
internshipCycle : z.string ( ) . nullish ( ) ,
@ -54,15 +63,6 @@ const offer = z.object({
totalCompensation : valuation.nullish ( ) , // Full time
} )
. nullish ( ) ,
comments : z.string ( ) ,
company : company.nullish ( ) ,
companyId : z.string ( ) ,
id : z.string ( ) . optional ( ) ,
jobType : z.string ( ) ,
location : z.string ( ) ,
monthYearReceived : z.date ( ) ,
negotiationStrategy : z.string ( ) ,
offersFullTimeId : z.string ( ) . nullish ( ) ,
offersInternId : z.string ( ) . nullish ( ) ,
profileId : z.string ( ) . nullish ( ) ,
} ) ;
@ -115,17 +115,17 @@ export const offersProfileRouter = createRouter()
include : {
overallHighestOffer : {
include : {
OffersFullTime : {
company : true ,
offersFullTime : {
include : {
totalCompensation : true ,
} ,
} ,
O ffersIntern: {
o ffersIntern: {
include : {
monthlySalary : true ,
} ,
} ,
company : true ,
profile : {
include : {
background : true ,
@ -135,17 +135,17 @@ export const offersProfileRouter = createRouter()
} ,
topCompanyOffers : {
include : {
OffersFullTime : {
company : true ,
offersFullTime : {
include : {
totalCompensation : true ,
} ,
} ,
O ffersIntern: {
o ffersIntern: {
include : {
monthlySalary : true ,
} ,
} ,
company : true ,
profile : {
include : {
background : {
@ -163,17 +163,17 @@ export const offersProfileRouter = createRouter()
} ,
topOverallOffers : {
include : {
OffersFullTime : {
company : true ,
offersFullTime : {
include : {
totalCompensation : true ,
} ,
} ,
O ffersIntern: {
o ffersIntern: {
include : {
monthlySalary : true ,
} ,
} ,
company : true ,
profile : {
include : {
background : {
@ -213,7 +213,8 @@ export const offersProfileRouter = createRouter()
} ,
offers : {
include : {
OffersFullTime : {
company : true ,
offersFullTime : {
include : {
baseSalary : true ,
bonus : true ,
@ -221,12 +222,11 @@ export const offersProfileRouter = createRouter()
totalCompensation : true ,
} ,
} ,
O ffersIntern: {
o ffersIntern: {
include : {
monthlySalary : true ,
} ,
} ,
company : true ,
} ,
} ,
} ,
@ -381,27 +381,53 @@ export const offersProfileRouter = createRouter()
create : input.offers.map ( ( x ) = > {
if (
x . jobType === 'INTERN' &&
x . O ffersIntern &&
x . O ffersIntern. internshipCycle &&
x . O ffersIntern. monthlySalary ? . currency &&
x . O ffersIntern. monthlySalary . value &&
x . O ffersIntern. startYear
x . o ffersIntern &&
x . o ffersIntern. internshipCycle &&
x . o ffersIntern. monthlySalary ? . currency &&
x . o ffersIntern. monthlySalary . value &&
x . o ffersIntern. startYear
) {
return {
OffersIntern : {
comments : x.comments ,
company : {
connect : {
id : x.companyId ,
} ,
} ,
jobType : x.jobType ,
location : x.location ,
monthYearReceived : x.monthYearReceived ,
negotiationStrategy : x.negotiationStrategy ,
offersIntern : {
create : {
internshipCycle : x.OffersIntern.internshipCycle ,
internshipCycle : x. o ffersIntern.internshipCycle,
monthlySalary : {
create : {
currency : x.OffersIntern.monthlySalary?.currency ,
value : x.OffersIntern.monthlySalary?.value ,
currency : x. o ffersIntern.monthlySalary?.currency,
value : x. o ffersIntern.monthlySalary?.value,
} ,
} ,
specialization : x.OffersIntern.specialization ,
startYear : x.OffersIntern.startYear ,
title : x. O ffersIntern.title,
specialization : x. o ffersIntern.specialization,
startYear : x. o ffersIntern.startYear,
title : x. o ffersIntern.title,
} ,
} ,
} ;
}
if (
x . jobType === 'FULLTIME' &&
x . offersFullTime &&
x . offersFullTime . baseSalary ? . currency &&
x . offersFullTime . baseSalary ? . value &&
x . offersFullTime . bonus ? . currency &&
x . offersFullTime . bonus ? . value &&
x . offersFullTime . stocks ? . currency &&
x . offersFullTime . stocks ? . value &&
x . offersFullTime . totalCompensation ? . currency &&
x . offersFullTime . totalCompensation ? . value &&
x . offersFullTime . level
) {
return {
comments : x.comments ,
company : {
connect : {
@ -412,64 +438,38 @@ export const offersProfileRouter = createRouter()
location : x.location ,
monthYearReceived : x.monthYearReceived ,
negotiationStrategy : x.negotiationStrategy ,
} ;
}
if (
x . jobType === 'FULLTIME' &&
x . OffersFullTime &&
x . OffersFullTime . baseSalary ? . currency &&
x . OffersFullTime . baseSalary ? . value &&
x . OffersFullTime . bonus ? . currency &&
x . OffersFullTime . bonus ? . value &&
x . OffersFullTime . stocks ? . currency &&
x . OffersFullTime . stocks ? . value &&
x . OffersFullTime . totalCompensation ? . currency &&
x . OffersFullTime . totalCompensation ? . value &&
x . OffersFullTime . level
) {
return {
OffersFullTime : {
offersFullTime : {
create : {
baseSalary : {
create : {
currency : x. O ffersFullTime.baseSalary?.currency,
value : x. O ffersFullTime.baseSalary?.value,
currency : x.offersFullTime.baseSalary?.currency ,
value : x.offersFullTime.baseSalary?.value ,
} ,
} ,
bonus : {
create : {
currency : x. O ffersFullTime.bonus?.currency,
value : x. O ffersFullTime.bonus?.value,
currency : x.offersFullTime.bonus?.currency ,
value : x.offersFullTime.bonus?.value ,
} ,
} ,
level : x. O ffersFullTime.level,
specialization : x. O ffersFullTime.specialization,
level : x.offersFullTime.level ,
specialization : x.offersFullTime.specialization ,
stocks : {
create : {
currency : x. O ffersFullTime.stocks?.currency,
value : x. O ffersFullTime.stocks?.value,
currency : x. o ffersFullTime.stocks?.currency,
value : x. o ffersFullTime.stocks?.value,
} ,
} ,
title : x. O ffersFullTime.title,
title : x. o ffersFullTime.title,
totalCompensation : {
create : {
currency :
x . O ffersFullTime. totalCompensation ? . currency ,
value : x. O ffersFullTime.totalCompensation?.value,
x . o ffersFullTime. totalCompensation ? . currency ,
value : x. o ffersFullTime.totalCompensation?.value,
} ,
} ,
} ,
} ,
comments : x.comments ,
company : {
connect : {
id : x.companyId ,
} ,
} ,
jobType : x.jobType ,
location : x.location ,
monthYearReceived : x.monthYearReceived ,
negotiationStrategy : x.negotiationStrategy ,
} ;
}
@ -813,127 +813,127 @@ export const offersProfileRouter = createRouter()
} ) ;
}
if ( offerToUpdate . O ffersIntern? . monthlySalary ) {
if ( offerToUpdate . o ffersIntern? . monthlySalary ) {
await ctx . prisma . offersIntern . update ( {
data : {
internshipCycle :
offerToUpdate . O ffersIntern. internshipCycle ? ? undefined ,
specialization : offerToUpdate. O ffersIntern.specialization,
startYear : offerToUpdate. O ffersIntern.startYear ? ? undefined ,
title : offerToUpdate. O ffersIntern.title,
offerToUpdate . o ffersIntern. internshipCycle ? ? undefined ,
specialization : offerToUpdate. o ffersIntern.specialization,
startYear : offerToUpdate. o ffersIntern.startYear ? ? undefined ,
title : offerToUpdate. o ffersIntern.title,
} ,
where : {
id : offerToUpdate. O ffersIntern.id,
id : offerToUpdate. o ffersIntern.id,
} ,
} ) ;
await ctx . prisma . offersCurrency . update ( {
data : {
currency : offerToUpdate. O ffersIntern.monthlySalary.currency,
value : offerToUpdate. O ffersIntern.monthlySalary.value,
currency : offerToUpdate. o ffersIntern.monthlySalary.currency,
value : offerToUpdate. o ffersIntern.monthlySalary.value,
} ,
where : {
id : offerToUpdate. O ffersIntern.monthlySalary.id,
id : offerToUpdate. o ffersIntern.monthlySalary.id,
} ,
} ) ;
}
if ( offerToUpdate . O ffersFullTime? . totalCompensation ) {
if ( offerToUpdate . o ffersFullTime? . totalCompensation ) {
await ctx . prisma . offersFullTime . update ( {
data : {
level : offerToUpdate. O ffersFullTime.level ? ? undefined ,
specialization : offerToUpdate. O ffersFullTime.specialization,
title : offerToUpdate. O ffersFullTime.title,
level : offerToUpdate. o ffersFullTime.level ? ? undefined ,
specialization : offerToUpdate. o ffersFullTime.specialization,
title : offerToUpdate. o ffersFullTime.title,
} ,
where : {
id : offerToUpdate. O ffersFullTime.id,
id : offerToUpdate. o ffersFullTime.id,
} ,
} ) ;
if ( offerToUpdate . O ffersFullTime. baseSalary ) {
if ( offerToUpdate . o ffersFullTime. baseSalary ) {
await ctx . prisma . offersCurrency . update ( {
data : {
currency : offerToUpdate. O ffersFullTime.baseSalary.currency,
value : offerToUpdate. O ffersFullTime.baseSalary.value,
currency : offerToUpdate. o ffersFullTime.baseSalary.currency,
value : offerToUpdate. o ffersFullTime.baseSalary.value,
} ,
where : {
id : offerToUpdate. O ffersFullTime.baseSalary.id,
id : offerToUpdate. o ffersFullTime.baseSalary.id,
} ,
} ) ;
}
if ( offerToUpdate . O ffersFullTime. bonus ) {
if ( offerToUpdate . o ffersFullTime. bonus ) {
await ctx . prisma . offersCurrency . update ( {
data : {
currency : offerToUpdate. O ffersFullTime.bonus.currency,
value : offerToUpdate. O ffersFullTime.bonus.value,
currency : offerToUpdate. o ffersFullTime.bonus.currency,
value : offerToUpdate. o ffersFullTime.bonus.value,
} ,
where : {
id : offerToUpdate. O ffersFullTime.bonus.id,
id : offerToUpdate. o ffersFullTime.bonus.id,
} ,
} ) ;
}
if ( offerToUpdate . O ffersFullTime. stocks ) {
if ( offerToUpdate . o ffersFullTime. stocks ) {
await ctx . prisma . offersCurrency . update ( {
data : {
currency : offerToUpdate. O ffersFullTime.stocks.currency,
value : offerToUpdate. O ffersFullTime.stocks.value,
currency : offerToUpdate. o ffersFullTime.stocks.currency,
value : offerToUpdate. o ffersFullTime.stocks.value,
} ,
where : {
id : offerToUpdate. O ffersFullTime.stocks.id,
id : offerToUpdate. o ffersFullTime.stocks.id,
} ,
} ) ;
}
await ctx . prisma . offersCurrency . update ( {
data : {
currency :
offerToUpdate . O ffersFullTime. totalCompensation . currency ,
value : offerToUpdate. O ffersFullTime.totalCompensation.value,
offerToUpdate . o ffersFullTime. totalCompensation . currency ,
value : offerToUpdate. o ffersFullTime.totalCompensation.value,
} ,
where : {
id : offerToUpdate. O ffersFullTime.totalCompensation.id,
id : offerToUpdate. o ffersFullTime.totalCompensation.id,
} ,
} ) ;
}
} else {
if (
offerToUpdate . jobType === 'INTERN' &&
offerToUpdate . O ffersIntern &&
offerToUpdate . O ffersIntern. internshipCycle &&
offerToUpdate . O ffersIntern. monthlySalary ? . currency &&
offerToUpdate . O ffersIntern. monthlySalary . value &&
offerToUpdate . O ffersIntern. startYear
offerToUpdate . o ffersIntern &&
offerToUpdate . o ffersIntern. internshipCycle &&
offerToUpdate . o ffersIntern. monthlySalary ? . currency &&
offerToUpdate . o ffersIntern. monthlySalary . value &&
offerToUpdate . o ffersIntern. startYear
) {
await ctx . prisma . offersProfile . update ( {
data : {
offers : {
create : {
OffersIntern : {
comments : offerToUpdate.comments ,
company : {
connect : {
id : offerToUpdate.companyId ,
} ,
} ,
jobType : offerToUpdate.jobType ,
location : offerToUpdate.location ,
monthYearReceived : offerToUpdate.monthYearReceived ,
negotiationStrategy : offerToUpdate.negotiationStrategy ,
offersIntern : {
create : {
internshipCycle :
offerToUpdate . OffersIntern . internshipCycle ,
offerToUpdate . o ffersIntern. internshipCycle ,
monthlySalary : {
create : {
currency :
offerToUpdate . OffersIntern . monthlySalary
offerToUpdate . o ffersIntern. monthlySalary
? . currency ,
value :
offerToUpdate . OffersIntern . monthlySalary ? . value ,
offerToUpdate . o ffersIntern. monthlySalary ? . value ,
} ,
} ,
specialization :
offerToUpdate . OffersIntern . specialization ,
startYear : offerToUpdate.OffersIntern.startYear ,
title : offerToUpdate.OffersIntern.title ,
} ,
} ,
comments : offerToUpdate.comments ,
company : {
connect : {
id : offerToUpdate.companyId ,
offerToUpdate . offersIntern . specialization ,
startYear : offerToUpdate.offersIntern.startYear ,
title : offerToUpdate.offersIntern.title ,
} ,
} ,
jobType : offerToUpdate.jobType ,
location : offerToUpdate.location ,
monthYearReceived : offerToUpdate.monthYearReceived ,
negotiationStrategy : offerToUpdate.negotiationStrategy ,
} ,
} ,
} ,
@ -944,72 +944,72 @@ export const offersProfileRouter = createRouter()
}
if (
offerToUpdate . jobType === 'FULLTIME' &&
offerToUpdate . O ffersFullTime &&
offerToUpdate . O ffersFullTime. baseSalary ? . currency &&
offerToUpdate . O ffersFullTime. baseSalary ? . value &&
offerToUpdate . O ffersFullTime. bonus ? . currency &&
offerToUpdate . O ffersFullTime. bonus ? . value &&
offerToUpdate . O ffersFullTime. stocks ? . currency &&
offerToUpdate . O ffersFullTime. stocks ? . value &&
offerToUpdate . O ffersFullTime. totalCompensation ? . currency &&
offerToUpdate . O ffersFullTime. totalCompensation ? . value &&
offerToUpdate . O ffersFullTime. level
offerToUpdate . o ffersFullTime &&
offerToUpdate . o ffersFullTime. baseSalary ? . currency &&
offerToUpdate . o ffersFullTime. baseSalary ? . value &&
offerToUpdate . o ffersFullTime. bonus ? . currency &&
offerToUpdate . o ffersFullTime. bonus ? . value &&
offerToUpdate . o ffersFullTime. stocks ? . currency &&
offerToUpdate . o ffersFullTime. stocks ? . value &&
offerToUpdate . o ffersFullTime. totalCompensation ? . currency &&
offerToUpdate . o ffersFullTime. totalCompensation ? . value &&
offerToUpdate . o ffersFullTime. level
) {
await ctx . prisma . offersProfile . update ( {
data : {
offers : {
create : {
OffersFullTime : {
comments : offerToUpdate.comments ,
company : {
connect : {
id : offerToUpdate.companyId ,
} ,
} ,
jobType : offerToUpdate.jobType ,
location : offerToUpdate.location ,
monthYearReceived : offerToUpdate.monthYearReceived ,
negotiationStrategy : offerToUpdate.negotiationStrategy ,
offersFullTime : {
create : {
baseSalary : {
create : {
currency :
offerToUpdate . OffersFullTime . baseSalary
offerToUpdate . o ffersFullTime. baseSalary
? . currency ,
value :
offerToUpdate . OffersFullTime . baseSalary ? . value ,
offerToUpdate . o ffersFullTime. baseSalary ? . value ,
} ,
} ,
bonus : {
create : {
currency :
offerToUpdate . O ffersFullTime. bonus ? . currency ,
value : offerToUpdate. O ffersFullTime.bonus?.value,
offerToUpdate . o ffersFullTime. bonus ? . currency ,
value : offerToUpdate. o ffersFullTime.bonus?.value,
} ,
} ,
level : offerToUpdate. O ffersFullTime.level,
level : offerToUpdate. o ffersFullTime.level,
specialization :
offerToUpdate . O ffersFullTime. specialization ,
offerToUpdate . o ffersFullTime. specialization ,
stocks : {
create : {
currency :
offerToUpdate . O ffersFullTime. stocks ? . currency ,
value : offerToUpdate. O ffersFullTime.stocks?.value,
offerToUpdate . o ffersFullTime. stocks ? . currency ,
value : offerToUpdate. o ffersFullTime.stocks?.value,
} ,
} ,
title : offerToUpdate. O ffersFullTime.title,
title : offerToUpdate. o ffersFullTime.title,
totalCompensation : {
create : {
currency :
offerToUpdate . O ffersFullTime. totalCompensation
offerToUpdate . o ffersFullTime. totalCompensation
? . currency ,
value :
offerToUpdate . O ffersFullTime. totalCompensation
offerToUpdate . o ffersFullTime. totalCompensation
? . value ,
} ,
} ,
} ,
} ,
comments : offerToUpdate.comments ,
company : {
connect : {
id : offerToUpdate.companyId ,
} ,
} ,
jobType : offerToUpdate.jobType ,
location : offerToUpdate.location ,
monthYearReceived : offerToUpdate.monthYearReceived ,
negotiationStrategy : offerToUpdate.negotiationStrategy ,
} ,
} ,
} ,
@ -1045,7 +1045,8 @@ export const offersProfileRouter = createRouter()
} ,
offers : {
include : {
OffersFullTime : {
company : true ,
offersFullTime : {
include : {
baseSalary : true ,
bonus : true ,
@ -1053,12 +1054,11 @@ export const offersProfileRouter = createRouter()
totalCompensation : true ,
} ,
} ,
O ffersIntern: {
o ffersIntern: {
include : {
monthlySalary : true ,
} ,
} ,
company : true ,
} ,
} ,
} ,