[questions][feat] update frontend to use companyId

pull/351/head
Jeff Sieu 3 years ago
parent b5d5a3d9ed
commit ee85a8e38f

@ -84,9 +84,8 @@ export default function ContributeQuestionForm({
name="company"
render={({ field }) => (
<CompaniesTypeahead
onSelect={({ label }) => {
// TODO: To change from using company name to company id (i.e., value)
field.onChange(label);
onSelect={({ id }) => {
field.onChange(id);
}}
/>
)}

@ -65,7 +65,7 @@ export default function QuestionsHomePage() {
[
'questions.questions.getQuestionsByFilter',
{
companies: selectedCompanies,
companyNames: selectedCompanies,
endDate: today,
locations: selectedLocations,
questionTypes: selectedQuestionTypes,
@ -252,7 +252,7 @@ export default function QuestionsHomePage() {
<ContributeQuestionCard
onSubmit={(data) => {
createQuestion({
company: data.company,
companyId: data.company,
content: data.questionContent,
location: data.location,
questionType: data.questionType,

@ -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(),
@ -51,35 +51,36 @@ export const questionsQuestionRouter = createProtectedRouter()
},
}
: {}),
encounters : {
encounters: {
some: {
...(input.companies.length > 0
...(input.companyNames.length > 0
? {
company : {
in : input.companies
}
company: {
name: {
in: input.companyNames,
},
},
}
: {}),
...(input.locations.length > 0
? {
location: {
in: input.locations
in: input.locations,
},
}
: {}),
...(input.roles.length > 0
? {
role : {
in: input.roles
}
role: {
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,

Loading…
Cancel
Save