diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx index e6dd0167..0ccd23e4 100644 --- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx +++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx @@ -48,6 +48,20 @@ type AnswerStatisticsProps = showAnswerStatistics?: false; }; +type AggregateStatisticsProps = + | { + companies: Record; + locations: Record; + roles: Record; + showAggregateStatistics: true; + } + | { + companies?: never; + locations?: never; + roles?: never; + showAggregateStatistics?: false; + }; + type ActionButtonProps = | { actionButtonLabel: string; @@ -90,16 +104,14 @@ type AddToListProps = export type BaseQuestionCardProps = ActionButtonProps & AddToListProps & + AggregateStatisticsProps & AnswerStatisticsProps & CreateEncounterProps & DeleteProps & ReceivedStatisticsProps & UpvoteProps & { - companies: Record; content: string; - locations: Record; questionId: string; - roles: Record; showHover?: boolean; timestamp: string; truncateContent?: boolean; @@ -114,6 +126,7 @@ export default function BaseQuestionCard({ receivedCount, type, showVoteButtons, + showAggregateStatistics, showAnswerStatistics, showReceivedStatistics, showCreateEncounterButton, @@ -145,12 +158,22 @@ export default function BaseQuestionCard({ /> )}
-
+
- - - - + {showAggregateStatistics && ( + <> + + + + + + )}

{timestamp}

{showAddToList && (
@@ -162,7 +185,7 @@ export default function BaseQuestionCard({
- {/*
- -
-

- Are these questions the same as yours? TODO:Change to list -

-
- { - // eslint-disable-next-line no-console - console.log('hi!'); +
+ +
+

+ Are these questions the same as yours? +

+
*/} +
+ {similarQuestions?.map((question) => ( + { + // eslint-disable-next-line no-console + console.log('hi!'); + }} + /> + ))} +
-
+
@@ -194,7 +238,7 @@ export default function ContributeQuestionForm({ diff --git a/apps/portal/src/server/router/questions-question-router.ts b/apps/portal/src/server/router/questions-question-router.ts index 254bdb47..812172dd 100644 --- a/apps/portal/src/server/router/questions-question-router.ts +++ b/apps/portal/src/server/router/questions-question-router.ts @@ -1,4 +1,5 @@ import { z } from 'zod'; +import type { QuestionsQuestion } from '@prisma/client'; import { QuestionsQuestionType, Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; @@ -207,14 +208,18 @@ export const questionsQuestionRouter = createProtectedRouter() .split(/\s+/) .join(' | '); - const relatedQuestions = await ctx.prisma.$queryRaw` + const relatedQuestions = (await ctx.prisma.$queryRaw` SELECT * FROM "QuestionsQuestion" - WHERE - "contentSearch" @@ to_tsquery('english', ${query}) - ORDER BY ts_rank("textSearch", to_tsquery('english', ${query})) DESC - `; + WHERE "contentSearch" @@ to_tsquery(${query}) + ORDER BY ts_rank("contentSearch", to_tsquery(${query})) DESC + `) as Array; - return relatedQuestions; + // Dummy data to make this return something + return await ctx.prisma.questionsQuestion.findMany({ + take: 5, + }); + + // Return relatedQuestions; }, }) .mutation('create', {