diff --git a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx index 29e1b3eb..3d625827 100644 --- a/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx +++ b/apps/portal/src/components/questions/forms/ContributeQuestionForm.tsx @@ -1,24 +1,14 @@ import { startOfMonth } from 'date-fns'; -import { useEffect, useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; -import { ArrowPathIcon } from '@heroicons/react/20/solid'; import type { QuestionsQuestionType } from '@prisma/client'; -import { - Button, - CheckboxInput, - HorizontalDivider, - Select, - TextArea, -} from '@tih/ui'; +import { Button, HorizontalDivider, Select, TextArea } from '@tih/ui'; import { LOCATIONS, QUESTION_TYPES, ROLES } from '~/utils/questions/constants'; import { useFormRegister, useSelectRegister, } from '~/utils/questions/useFormRegister'; -import { trpc } from '~/utils/trpc'; -import SimilarQuestionCard from '../card/question/SimilarQuestionCard'; import CompanyTypeahead from '../typeahead/CompanyTypeahead'; import LocationTypeahead from '../typeahead/LocationTypeahead'; import RoleTypeahead from '../typeahead/RoleTypeahead'; @@ -48,39 +38,15 @@ export default function ContributeQuestionForm({ control, register: formRegister, handleSubmit, - watch, } = useForm({ defaultValues: { date: startOfMonth(new Date()), }, }); - const [contentToCheck, setContentToCheck] = useState(''); - - const { data: similarQuestions } = trpc.useQuery( - [ - 'questions.questions.getRelatedQuestionsByContent', - { content: contentToCheck }, - ], - { - keepPreviousData: true, - }, - ); - const questionContent = watch('questionContent'); const register = useFormRegister(formRegister); const selectRegister = useSelectRegister(formRegister); - const [checkedSimilar, setCheckedSimilar] = useState(false); - const handleCheckSimilarQuestions = (checked: boolean) => { - setCheckedSimilar(checked); - }; - - useEffect(() => { - if (questionContent !== contentToCheck) { - setCheckedSimilar(false); - } - }, [questionContent, contentToCheck]); - return (
-

- Are these questions the same as yours? -

- diff --git a/apps/portal/src/server/router/questions-question-router.ts b/apps/portal/src/server/router/questions-question-router.ts index 2eb4de14..961843d7 100644 --- a/apps/portal/src/server/router/questions-question-router.ts +++ b/apps/portal/src/server/router/questions-question-router.ts @@ -1,5 +1,4 @@ import { z } from 'zod'; -import type { QuestionsQuestion } from '@prisma/client'; import { QuestionsQuestionType, Vote } from '@prisma/client'; import { TRPCError } from '@trpc/server'; @@ -195,29 +194,6 @@ export const questionsQuestionRouter = createProtectedRouter() return createQuestionWithAggregateData(questionData); }, }) - .query('getRelatedQuestionsByContent', { - input: z.object({ - content: z.string(), - }), - async resolve({ ctx, input }) { - const escapeChars = /[()|&:*!]/g; - - const query = input.content - .replace(escapeChars, ' ') - .trim() - .split(/\s+/) - .join(' | '); - - const relatedQuestions = (await ctx.prisma.$queryRaw` - SELECT "id", "userId", "content", "createdAt", "updatedAt", "questionType", "lastSeenAt", "upvotes" FROM "QuestionsQuestion" - WHERE - "contentSearch" @@ to_tsquery('english', ${query}) - ORDER BY ts_rank("contentSearch", to_tsquery('english', ${query})) DESC - `) as Array; - - return relatedQuestions; - }, - }) .mutation('create', { input: z.object({ companyId: z.string(),