+
{fileUploadError && (
{fileUploadError}
diff --git a/apps/portal/src/server/router/offers/offers-profile-router.ts b/apps/portal/src/server/router/offers/offers-profile-router.ts
index 9cac7feb..f71d9c48 100644
--- a/apps/portal/src/server/router/offers/offers-profile-router.ts
+++ b/apps/portal/src/server/router/offers/offers-profile-router.ts
@@ -10,7 +10,10 @@ import {
} from '~/mappers/offers-mappers';
import { baseCurrencyString } from '~/utils/offers/currency';
import { convert } from '~/utils/offers/currency/currencyExchange';
-import { generateRandomName, generateRandomStringForToken } from '~/utils/offers/randomGenerator';
+import {
+ generateRandomName,
+ generateRandomStringForToken,
+} from '~/utils/offers/randomGenerator';
import { createValidationRegex } from '~/utils/offers/zodRegex';
import { createRouter } from '../context';
@@ -48,7 +51,6 @@ const offer = z.object({
bonusId: z.string().nullish(),
id: z.string().optional(),
level: z.string().nullish(),
- specialization: z.string(),
stocks: valuation.nullish(),
stocksId: z.string().nullish(),
title: z.string(),
@@ -62,7 +64,6 @@ const offer = z.object({
id: z.string().optional(),
internshipCycle: z.string().nullish(),
monthlySalary: valuation.nullish(),
- specialization: z.string(),
startYear: z.number().nullish(),
title: z.string(),
totalCompensation: valuation.nullish(), // Full time
@@ -86,7 +87,6 @@ const experience = z.object({
location: z.string().nullish(),
monthlySalary: valuation.nullish(),
monthlySalaryId: z.string().nullish(),
- specialization: z.string().nullish(),
title: z.string().nullish(),
totalCompensation: valuation.nullish(),
totalCompensationId: z.string().nullish(),
@@ -285,11 +285,7 @@ export const offersProfileRouter = createRouter()
},
experiences: {
create: input.background.experiences.map(async (x) => {
- if (
- x.jobType === JobType.FULLTIME &&
- x.totalCompensation?.currency != null &&
- x.totalCompensation?.value != null
- ) {
+ if (x.jobType === JobType.FULLTIME) {
if (x.companyId) {
return {
company: {
@@ -300,20 +296,22 @@ export const offersProfileRouter = createRouter()
durationInMonths: x.durationInMonths,
jobType: x.jobType,
level: x.level,
- specialization: x.specialization,
title: x.title,
- totalCompensation: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.totalCompensation.value,
- x.totalCompensation.currency,
- baseCurrencyString,
- ),
- currency: x.totalCompensation.currency,
- value: x.totalCompensation.value,
- },
- },
+ totalCompensation:
+ x.totalCompensation != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.totalCompensation.value,
+ x.totalCompensation.currency,
+ baseCurrencyString,
+ ),
+ currency: x.totalCompensation.currency,
+ value: x.totalCompensation.value,
+ },
+ }
+ : undefined,
};
}
return {
@@ -321,27 +319,25 @@ export const offersProfileRouter = createRouter()
jobType: x.jobType,
level: x.level,
location: x.location,
- specialization: x.specialization,
title: x.title,
- totalCompensation: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.totalCompensation.value,
- x.totalCompensation.currency,
- baseCurrencyString,
- ),
- currency: x.totalCompensation.currency,
- value: x.totalCompensation.value,
- },
- },
+ totalCompensation:
+ x.totalCompensation != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.totalCompensation.value,
+ x.totalCompensation.currency,
+ baseCurrencyString,
+ ),
+ currency: x.totalCompensation.currency,
+ value: x.totalCompensation.value,
+ },
+ }
+ : undefined,
};
}
- if (
- x.jobType === JobType.INTERN &&
- x.monthlySalary?.currency != null &&
- x.monthlySalary?.value != null
- ) {
+ if (x.jobType === JobType.INTERN) {
if (x.companyId) {
return {
company: {
@@ -351,38 +347,42 @@ export const offersProfileRouter = createRouter()
},
durationInMonths: x.durationInMonths,
jobType: x.jobType,
- monthlySalary: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.monthlySalary.value,
- x.monthlySalary.currency,
- baseCurrencyString,
- ),
- currency: x.monthlySalary.currency,
- value: x.monthlySalary.value,
- },
- },
- specialization: x.specialization,
+ monthlySalary:
+ x.monthlySalary != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.monthlySalary.value,
+ x.monthlySalary.currency,
+ baseCurrencyString,
+ ),
+ currency: x.monthlySalary.currency,
+ value: x.monthlySalary.value,
+ },
+ }
+ : undefined,
title: x.title,
};
}
return {
durationInMonths: x.durationInMonths,
jobType: x.jobType,
- monthlySalary: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.monthlySalary.value,
- x.monthlySalary.currency,
- baseCurrencyString,
- ),
- currency: x.monthlySalary.currency,
- value: x.monthlySalary.value,
- },
- },
- specialization: x.specialization,
+ monthlySalary:
+ x.monthlySalary != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.monthlySalary.value,
+ x.monthlySalary.currency,
+ baseCurrencyString,
+ ),
+ currency: x.monthlySalary.currency,
+ value: x.monthlySalary.value,
+ },
+ }
+ : undefined,
title: x.title,
};
}
@@ -442,7 +442,6 @@ export const offersProfileRouter = createRouter()
value: x.offersIntern.monthlySalary.value,
},
},
- specialization: x.offersIntern.specialization,
startYear: x.offersIntern.startYear,
title: x.offersIntern.title,
},
@@ -452,17 +451,10 @@ export const offersProfileRouter = createRouter()
if (
x.jobType === JobType.FULLTIME &&
x.offersFullTime &&
- x.offersFullTime.baseSalary?.currency != null &&
- x.offersFullTime.baseSalary?.value != null &&
- x.offersFullTime.bonus?.currency != null &&
- x.offersFullTime.bonus?.value != null &&
- x.offersFullTime.stocks?.currency != null &&
- x.offersFullTime.stocks?.value != null &&
x.offersFullTime.totalCompensation?.currency != null &&
x.offersFullTime.totalCompensation?.value != null &&
x.offersFullTime.level != null &&
- x.offersFullTime.title != null &&
- x.offersFullTime.specialization != null
+ x.offersFullTime.title != null
) {
return {
comments: x.comments,
@@ -477,44 +469,53 @@ export const offersProfileRouter = createRouter()
negotiationStrategy: x.negotiationStrategy,
offersFullTime: {
create: {
- baseSalary: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.offersFullTime.baseSalary.value,
- x.offersFullTime.baseSalary.currency,
- baseCurrencyString,
- ),
- currency: x.offersFullTime.baseSalary.currency,
- value: x.offersFullTime.baseSalary.value,
- },
- },
- bonus: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.offersFullTime.bonus.value,
- x.offersFullTime.bonus.currency,
- baseCurrencyString,
- ),
- currency: x.offersFullTime.bonus.currency,
- value: x.offersFullTime.bonus.value,
- },
- },
+ baseSalary:
+ x.offersFullTime?.baseSalary != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.offersFullTime.baseSalary.value,
+ x.offersFullTime.baseSalary.currency,
+ baseCurrencyString,
+ ),
+ currency:
+ x.offersFullTime.baseSalary.currency,
+ value: x.offersFullTime.baseSalary.value,
+ },
+ }
+ : undefined,
+ bonus:
+ x.offersFullTime?.bonus != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.offersFullTime.bonus.value,
+ x.offersFullTime.bonus.currency,
+ baseCurrencyString,
+ ),
+ currency: x.offersFullTime.bonus.currency,
+ value: x.offersFullTime.bonus.value,
+ },
+ }
+ : undefined,
level: x.offersFullTime.level,
- specialization: x.offersFullTime.specialization,
- stocks: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- x.offersFullTime.stocks.value,
- x.offersFullTime.stocks.currency,
- baseCurrencyString,
- ),
- currency: x.offersFullTime.stocks.currency,
- value: x.offersFullTime.stocks.value,
- },
- },
+ stocks:
+ x.offersFullTime?.stocks != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ x.offersFullTime.stocks.value,
+ x.offersFullTime.stocks.currency,
+ baseCurrencyString,
+ ),
+ currency: x.offersFullTime.stocks.currency,
+ value: x.offersFullTime.stocks.value,
+ },
+ }
+ : undefined,
title: x.offersFullTime.title,
totalCompensation: {
create: {
@@ -713,8 +714,8 @@ export const offersProfileRouter = createRouter()
data: {
companyId: exp.companyId, // TODO: check if can change with connect or whether there is a difference
durationInMonths: exp.durationInMonths,
+ jobType: exp.jobType as JobType,
level: exp.level,
- specialization: exp.specialization,
},
where: {
id: exp.id,
@@ -821,20 +822,21 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType,
level: exp.level,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
- totalCompensation: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- exp.totalCompensation.value,
- exp.totalCompensation.currency,
- baseCurrencyString,
- ),
- currency: exp.totalCompensation.currency,
- value: exp.totalCompensation.value,
- },
- },
+ totalCompensation: exp.totalCompensation
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ exp.totalCompensation.value,
+ exp.totalCompensation.currency,
+ baseCurrencyString,
+ ),
+ currency: exp.totalCompensation.currency,
+ value: exp.totalCompensation.value,
+ },
+ }
+ : undefined,
},
},
},
@@ -851,7 +853,6 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType,
level: exp.level,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
totalCompensation: {
create: {
@@ -887,7 +888,6 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType,
level: exp.level,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -905,7 +905,6 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType,
level: exp.level,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -945,7 +944,6 @@ export const offersProfileRouter = createRouter()
value: exp.monthlySalary.value,
},
},
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -974,7 +972,6 @@ export const offersProfileRouter = createRouter()
value: exp.monthlySalary.value,
},
},
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -997,7 +994,6 @@ export const offersProfileRouter = createRouter()
durationInMonths: exp.durationInMonths,
jobType: exp.jobType,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -1014,7 +1010,6 @@ export const offersProfileRouter = createRouter()
durationInMonths: exp.durationInMonths,
jobType: exp.jobType,
location: exp.location,
- specialization: exp.specialization,
title: exp.title,
},
},
@@ -1121,7 +1116,6 @@ export const offersProfileRouter = createRouter()
data: {
internshipCycle:
offerToUpdate.offersIntern.internshipCycle ?? undefined,
- specialization: offerToUpdate.offersIntern.specialization,
startYear: offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title,
},
@@ -1150,7 +1144,6 @@ export const offersProfileRouter = createRouter()
await ctx.prisma.offersFullTime.update({
data: {
level: offerToUpdate.offersFullTime.level ?? undefined,
- specialization: offerToUpdate.offersFullTime.specialization,
title: offerToUpdate.offersFullTime.title,
},
where: {
@@ -1174,7 +1167,7 @@ export const offersProfileRouter = createRouter()
},
});
}
- if (offerToUpdate.offersFullTime.bonus) {
+ if (offerToUpdate.offersFullTime.bonus != null) {
await ctx.prisma.offersCurrency.update({
data: {
baseCurrency: baseCurrencyString,
@@ -1191,7 +1184,7 @@ export const offersProfileRouter = createRouter()
},
});
}
- if (offerToUpdate.offersFullTime.stocks) {
+ if (offerToUpdate.offersFullTime.stocks != null) {
await ctx.prisma.offersCurrency.update({
data: {
baseCurrency: baseCurrencyString,
@@ -1269,8 +1262,6 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersIntern.monthlySalary.value,
},
},
- specialization:
- offerToUpdate.offersIntern.specialization,
startYear: offerToUpdate.offersIntern.startYear,
title: offerToUpdate.offersIntern.title,
},
@@ -1286,12 +1277,6 @@ export const offersProfileRouter = createRouter()
if (
offerToUpdate.jobType === JobType.FULLTIME &&
offerToUpdate.offersFullTime &&
- offerToUpdate.offersFullTime.baseSalary?.currency != null &&
- offerToUpdate.offersFullTime.baseSalary?.value != null &&
- offerToUpdate.offersFullTime.bonus?.currency != null &&
- offerToUpdate.offersFullTime.bonus?.value != null &&
- offerToUpdate.offersFullTime.stocks?.currency != null &&
- offerToUpdate.offersFullTime.stocks?.value != null &&
offerToUpdate.offersFullTime.totalCompensation?.currency !=
null &&
offerToUpdate.offersFullTime.totalCompensation?.value != null &&
@@ -1313,51 +1298,66 @@ export const offersProfileRouter = createRouter()
negotiationStrategy: offerToUpdate.negotiationStrategy,
offersFullTime: {
create: {
- baseSalary: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- offerToUpdate.offersFullTime.baseSalary.value,
- offerToUpdate.offersFullTime.baseSalary
- .currency,
- baseCurrencyString,
- ),
- currency:
- offerToUpdate.offersFullTime.baseSalary
- .currency,
- value:
- offerToUpdate.offersFullTime.baseSalary.value,
- },
- },
- bonus: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- offerToUpdate.offersFullTime.bonus.value,
- offerToUpdate.offersFullTime.bonus.currency,
- baseCurrencyString,
- ),
- currency:
- offerToUpdate.offersFullTime.bonus.currency,
- value: offerToUpdate.offersFullTime.bonus.value,
- },
- },
+ baseSalary:
+ offerToUpdate.offersFullTime?.baseSalary != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ offerToUpdate.offersFullTime.baseSalary
+ .value,
+ offerToUpdate.offersFullTime.baseSalary
+ .currency,
+ baseCurrencyString,
+ ),
+ currency:
+ offerToUpdate.offersFullTime.baseSalary
+ .currency,
+ value:
+ offerToUpdate.offersFullTime.baseSalary
+ .value,
+ },
+ }
+ : undefined,
+ bonus:
+ offerToUpdate.offersFullTime?.bonus != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ offerToUpdate.offersFullTime.bonus.value,
+ offerToUpdate.offersFullTime.bonus
+ .currency,
+ baseCurrencyString,
+ ),
+ currency:
+ offerToUpdate.offersFullTime.bonus
+ .currency,
+ value:
+ offerToUpdate.offersFullTime.bonus.value,
+ },
+ }
+ : undefined,
level: offerToUpdate.offersFullTime.level,
- specialization:
- offerToUpdate.offersFullTime.specialization,
- stocks: {
- create: {
- baseCurrency: baseCurrencyString,
- baseValue: await convert(
- offerToUpdate.offersFullTime.stocks.value,
- offerToUpdate.offersFullTime.stocks.currency,
- baseCurrencyString,
- ),
- currency:
- offerToUpdate.offersFullTime.stocks.currency,
- value: offerToUpdate.offersFullTime.stocks.value,
- },
- },
+ stocks:
+ offerToUpdate.offersFullTime?.stocks != null
+ ? {
+ create: {
+ baseCurrency: baseCurrencyString,
+ baseValue: await convert(
+ offerToUpdate.offersFullTime.stocks.value,
+ offerToUpdate.offersFullTime.stocks
+ .currency,
+ baseCurrencyString,
+ ),
+ currency:
+ offerToUpdate.offersFullTime.stocks
+ .currency,
+ value:
+ offerToUpdate.offersFullTime.stocks.value,
+ },
+ }
+ : undefined,
title: offerToUpdate.offersFullTime.title,
totalCompensation: {
create: {
diff --git a/apps/portal/src/server/router/offers/offers.ts b/apps/portal/src/server/router/offers/offers.ts
index b333fa66..7d5ff908 100644
--- a/apps/portal/src/server/router/offers/offers.ts
+++ b/apps/portal/src/server/router/offers/offers.ts
@@ -73,7 +73,7 @@ export const offersRouter = createRouter().query('list', {
const order = getOrder(input.sortBy.charAt(0));
const sortingKey = input.sortBy.substring(1);
- let data = !yoeRange
+ const data = !yoeRange
? await ctx.prisma.offersOffer.findMany({
// Internship
include: {
@@ -303,11 +303,18 @@ export const offersRouter = createRouter().query('list', {
},
});
+ const startRecordIndex: number = input.limit * input.offset;
+ const endRecordIndex: number =
+ startRecordIndex + input.limit <= data.length
+ ? startRecordIndex + input.limit
+ : data.length;
+ let paginatedData = data.slice(startRecordIndex, endRecordIndex);
+
// CONVERTING
const currency = input.currency?.toUpperCase();
if (currency != null && currency in Currency) {
- data = await Promise.all(
- data.map(async (offer) => {
+ paginatedData = await Promise.all(
+ paginatedData.map(async (offer) => {
if (offer.offersFullTime?.totalCompensation != null) {
offer.offersFullTime.totalCompensation.value =
await convertWithDate(
@@ -317,27 +324,36 @@ export const offersRouter = createRouter().query('list', {
offer.offersFullTime.totalCompensation.updatedAt,
);
offer.offersFullTime.totalCompensation.currency = currency;
- offer.offersFullTime.baseSalary.value = await convertWithDate(
- offer.offersFullTime.baseSalary.value,
- offer.offersFullTime.baseSalary.currency,
- currency,
- offer.offersFullTime.baseSalary.updatedAt,
- );
- offer.offersFullTime.baseSalary.currency = currency;
- offer.offersFullTime.stocks.value = await convertWithDate(
- offer.offersFullTime.stocks.value,
- offer.offersFullTime.stocks.currency,
- currency,
- offer.offersFullTime.stocks.updatedAt,
- );
- offer.offersFullTime.stocks.currency = currency;
- offer.offersFullTime.bonus.value = await convertWithDate(
- offer.offersFullTime.bonus.value,
- offer.offersFullTime.bonus.currency,
- currency,
- offer.offersFullTime.bonus.updatedAt,
- );
- offer.offersFullTime.bonus.currency = currency;
+
+ if (offer.offersFullTime?.baseSalary != null) {
+ offer.offersFullTime.baseSalary.value = await convertWithDate(
+ offer.offersFullTime.baseSalary.value,
+ offer.offersFullTime.baseSalary.currency,
+ currency,
+ offer.offersFullTime.baseSalary.updatedAt,
+ );
+ offer.offersFullTime.baseSalary.currency = currency;
+ }
+
+ if (offer.offersFullTime?.stocks != null) {
+ offer.offersFullTime.stocks.value = await convertWithDate(
+ offer.offersFullTime.stocks.value,
+ offer.offersFullTime.stocks.currency,
+ currency,
+ offer.offersFullTime.stocks.updatedAt,
+ );
+ offer.offersFullTime.stocks.currency = currency;
+ }
+
+ if (offer.offersFullTime?.bonus != null) {
+ offer.offersFullTime.bonus.value = await convertWithDate(
+ offer.offersFullTime.bonus.value,
+ offer.offersFullTime.bonus.currency,
+ currency,
+ offer.offersFullTime.bonus.updatedAt,
+ );
+ offer.offersFullTime.bonus.currency = currency;
+ }
} else if (offer.offersIntern?.monthlySalary != null) {
offer.offersIntern.monthlySalary.value = await convertWithDate(
offer.offersIntern.monthlySalary.value,
@@ -358,13 +374,6 @@ export const offersRouter = createRouter().query('list', {
);
}
- const startRecordIndex: number = input.limit * input.offset;
- const endRecordIndex: number =
- startRecordIndex + input.limit <= data.length
- ? startRecordIndex + input.limit
- : data.length;
- const paginatedData = data.slice(startRecordIndex, endRecordIndex);
-
return getOffersResponseMapper(
paginatedData.map((offer) => dashboardOfferDtoMapper(offer)),
{
diff --git a/apps/portal/src/server/router/questions-list-crud.ts b/apps/portal/src/server/router/questions-list-crud.ts
new file mode 100644
index 00000000..1f375497
--- /dev/null
+++ b/apps/portal/src/server/router/questions-list-crud.ts
@@ -0,0 +1,199 @@
+import { z } from 'zod';
+import { TRPCError } from '@trpc/server';
+
+import { createProtectedRouter } from './context';
+
+export const questionListRouter = createProtectedRouter()
+ .query('getListsByUser', {
+ async resolve({ ctx }) {
+ const userId = ctx.session?.user?.id;
+
+ return await ctx.prisma.questionsList.findMany({
+ include: {
+ questionEntries: {
+ include: {
+ question: true,
+ },
+ }
+ },
+ orderBy: {
+ createdAt: 'asc',
+ },
+ where: {
+ id: userId,
+ },
+ });
+ }
+ })
+ .query('getListById', {
+ input: z.object({
+ listId: z.string(),
+ }),
+ async resolve({ ctx }) {
+ const userId = ctx.session?.user?.id;
+
+ return await ctx.prisma.questionsList.findMany({
+ include: {
+ questionEntries: {
+ include: {
+ question: true,
+ },
+ }
+ },
+ orderBy: {
+ createdAt: 'asc',
+ },
+ where: {
+ id: userId,
+ },
+ });
+ }
+ })
+ .mutation('create', {
+ input: z.object({
+ name: z.string(),
+ }),
+ async resolve({ ctx, input }) {
+ const userId = ctx.session?.user?.id;
+
+ const { name } = input;
+
+ return await ctx.prisma.questionsList.create({
+ data: {
+ name,
+ userId,
+ },
+ });
+ },
+ })
+ .mutation('update', {
+ input: z.object({
+ id: z.string(),
+ name: z.string().optional(),
+ }),
+ async resolve({ ctx, input }) {
+ const userId = ctx.session?.user?.id;
+ const { name, id } = input;
+
+ const listToUpdate = await ctx.prisma.questionsList.findUnique({
+ where: {
+ id: input.id,
+ },
+ });
+
+ if (listToUpdate?.id !== userId) {
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: 'User have no authorization to record.',
+ });
+ }
+
+ return await ctx.prisma.questionsList.update({
+ data: {
+ name,
+ },
+ where: {
+ id,
+ },
+ });
+ },
+ })
+ .mutation('delete', {
+ input: z.object({
+ id: z.string(),
+ }),
+ async resolve({ ctx, input }) {
+ const userId = ctx.session?.user?.id;
+
+ const listToDelete = await ctx.prisma.questionsList.findUnique({
+ where: {
+ id: input.id,
+ },
+ });
+
+ if (listToDelete?.id !== userId) {
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: 'User have no authorization to record.',
+ });
+ }
+
+ return await ctx.prisma.questionsList.delete({
+ where: {
+ id: input.id,
+ },
+ });
+ },
+ })
+ .mutation('createQuestionEntry', {
+ input: z.object({
+ listId: z.string(),
+ questionId: z.string(),
+ }),
+ async resolve({ ctx, input }) {
+ const userId = ctx.session?.user?.id;
+
+ const listToAugment = await ctx.prisma.questionsList.findUnique({
+ where: {
+ id: input.listId,
+ },
+ });
+
+ if (listToAugment?.id !== userId) {
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: 'User have no authorization to record.',
+ });
+ }
+
+ const { questionId, listId } = input;
+
+ return await ctx.prisma.questionsListQuestionEntry.create({
+ data: {
+ listId,
+ questionId,
+ },
+ });
+ },
+ })
+ .mutation('deleteQuestionEntry', {
+ input: z.object({
+ id: z.string(),
+ }),
+ async resolve({ ctx, input }) {
+ const userId = ctx.session?.user?.id;
+
+ const entryToDelete = await ctx.prisma.questionsListQuestionEntry.findUnique({
+ where: {
+ id: input.id,
+ },
+ });
+
+ if (entryToDelete?.id !== userId) {
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: 'User have no authorization to record.',
+ });
+ }
+
+
+ const listToAugment = await ctx.prisma.questionsList.findUnique({
+ where: {
+ id: entryToDelete.listId,
+ },
+ });
+
+ if (listToAugment?.id !== userId) {
+ throw new TRPCError({
+ code: 'UNAUTHORIZED',
+ message: 'User have no authorization to record.',
+ });
+ }
+
+ return await ctx.prisma.questionsListQuestionEntry.delete({
+ where: {
+ id: input.id,
+ },
+ });
+ },
+ });
diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts
index 487ae0c9..f2b26332 100644
--- a/apps/portal/src/types/offers.d.ts
+++ b/apps/portal/src/types/offers.d.ts
@@ -26,7 +26,6 @@ export type Experience = {
level: string?;
location: string?;
monthlySalary: Valuation?;
- specialization: string?;
title: string?;
totalCompensation: Valuation?;
};
@@ -87,12 +86,11 @@ export type ProfileOffer = {
};
export type FullTime = {
- baseSalary: Valuation;
- bonus: Valuation;
+ baseSalary: Valuation?;
+ bonus: Valuation?;
id: string;
level: string;
- specialization: string;
- stocks: Valuation;
+ stocks: Valuation?;
title: string;
totalCompensation: Valuation;
};
@@ -101,7 +99,6 @@ export type Intern = {
id: string;
internshipCycle: string;
monthlySalary: Valuation;
- specialization: string;
startYear: number;
title: string;
};
@@ -163,7 +160,6 @@ export type AnalysisHighestOffer = {
id: string;
level: string;
location: string;
- specialization: string;
totalYoe: number;
};
@@ -178,7 +174,6 @@ export type AnalysisOffer = {
negotiationStrategy: string;
previousCompanies: Array
;
profileName: string;
- specialization: string;
title: string;
totalYoe: number;
};
diff --git a/apps/portal/src/utils/offers/analysisGeneration.ts b/apps/portal/src/utils/offers/analysisGeneration.ts
index c017417a..759faadf 100644
--- a/apps/portal/src/utils/offers/analysisGeneration.ts
+++ b/apps/portal/src/utils/offers/analysisGeneration.ts
@@ -19,9 +19,9 @@ const searchOfferPercentile = (
company: Company;
offersFullTime:
| (OffersFullTime & {
- baseSalary: OffersCurrency;
- bonus: OffersCurrency;
- stocks: OffersCurrency;
+ baseSalary: OffersCurrency | null;
+ bonus: OffersCurrency | null;
+ stocks: OffersCurrency | null;
totalCompensation: OffersCurrency;
})
| null;
diff --git a/apps/portal/src/utils/offers/form.tsx b/apps/portal/src/utils/offers/form.tsx
index 2e88ac88..ac03e281 100644
--- a/apps/portal/src/utils/offers/form.tsx
+++ b/apps/portal/src/utils/offers/form.tsx
@@ -32,6 +32,33 @@ export function cleanObject(object: any) {
return object;
}
+/**
+ * Removes empty objects from an object.
+ * @param object
+ * @returns object without empty values or objects.
+ */
+export function removeEmptyObjects(object: any) {
+ Object.entries(object).forEach(([k, v]) => {
+ if ((v && typeof v === 'object') || Array.isArray(v)) {
+ removeEmptyObjects(v);
+ }
+ if (
+ v &&
+ typeof v === 'object' &&
+ !Object.keys(v).length &&
+ !Array.isArray(v)
+ ) {
+ if (Array.isArray(object)) {
+ const index = object.indexOf(v);
+ object.splice(index, 1);
+ } else if (!(v instanceof Date)) {
+ delete object[k];
+ }
+ }
+ });
+ return object;
+}
+
/**
* Removes invalid money data from an object.
* If currency is present but value is not present, money object is removed.
diff --git a/packages/ui/src/TextInput/TextInput.tsx b/packages/ui/src/TextInput/TextInput.tsx
index 98b150f2..81f64190 100644
--- a/packages/ui/src/TextInput/TextInput.tsx
+++ b/packages/ui/src/TextInput/TextInput.tsx
@@ -154,14 +154,14 @@ function TextInput(
switch (startAddOnType) {
case 'label':
return (
-
+
{startAddOn}
);
case 'icon': {
const StartAddOn = startAddOn;
return (
-