|
|
|
@ -9,7 +9,7 @@ import type { Question } from '~/types/questions';
|
|
|
|
|
export const questionsQuestionRouter = createProtectedRouter()
|
|
|
|
|
.query('getQuestionsByFilter', {
|
|
|
|
|
input: z.object({
|
|
|
|
|
companyIds: z.string().array(),
|
|
|
|
|
companyNames: z.string().array(),
|
|
|
|
|
endDate: z.date(),
|
|
|
|
|
locations: z.string().array(),
|
|
|
|
|
questionTypes: z.nativeEnum(QuestionsQuestionType).array(),
|
|
|
|
@ -53,33 +53,34 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|
|
|
|
: {}),
|
|
|
|
|
encounters: {
|
|
|
|
|
some: {
|
|
|
|
|
...(input.companies.length > 0
|
|
|
|
|
...(input.companyNames.length > 0
|
|
|
|
|
? {
|
|
|
|
|
company: {
|
|
|
|
|
in : input.companies
|
|
|
|
|
}
|
|
|
|
|
name: {
|
|
|
|
|
in: input.companyNames,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...(input.locations.length > 0
|
|
|
|
|
? {
|
|
|
|
|
location: {
|
|
|
|
|
in: input.locations
|
|
|
|
|
in: input.locations,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
...(input.roles.length > 0
|
|
|
|
|
? {
|
|
|
|
|
role: {
|
|
|
|
|
in: input.roles
|
|
|
|
|
}
|
|
|
|
|
in: input.roles,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
: {}),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
return questionsData
|
|
|
|
|
.map((data) => {
|
|
|
|
|
return questionsData.map((data) => {
|
|
|
|
|
const votes: number = data.votes.reduce(
|
|
|
|
|
(previousValue: number, currentValue) => {
|
|
|
|
|
let result: number = previousValue;
|
|
|
|
@ -205,11 +206,19 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|
|
|
|
encounters: {
|
|
|
|
|
create: [
|
|
|
|
|
{
|
|
|
|
|
company: input.companyId,
|
|
|
|
|
company: {
|
|
|
|
|
connect: {
|
|
|
|
|
id: input.companyId,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
location: input.location,
|
|
|
|
|
role: input.role,
|
|
|
|
|
seenAt: input.seenAt,
|
|
|
|
|
userId,
|
|
|
|
|
user: {
|
|
|
|
|
connect: {
|
|
|
|
|
id: userId,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
},
|
|
|
|
@ -245,7 +254,6 @@ export const questionsQuestionRouter = createProtectedRouter()
|
|
|
|
|
const { content, questionType } = input;
|
|
|
|
|
|
|
|
|
|
return await ctx.prisma.questionsQuestion.update({
|
|
|
|
|
|
|
|
|
|
data: {
|
|
|
|
|
content,
|
|
|
|
|
questionType,
|
|
|
|
|