From 2c29d8ae3ca215b3cbc13746db97cd6178d293fb Mon Sep 17 00:00:00 2001 From: Brandon Egger Date: Fri, 17 Mar 2023 19:17:33 -0500 Subject: [PATCH] add all search queries to result set --- src/pages/resources/search.tsx | 18 ++++++++++++------ src/server/api/routers/auditoryResources.ts | 18 +++++++++++++++++- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/pages/resources/search.tsx b/src/pages/resources/search.tsx index f9d236b..ec91013 100644 --- a/src/pages/resources/search.tsx +++ b/src/pages/resources/search.tsx @@ -11,6 +11,7 @@ interface Option { interface Question { for: string, header: string, + question: string, options: Option[] } @@ -18,17 +19,18 @@ const questions: Question[] = [ { for: "ages", header: "Age of Patient", + question: "How old is the patient?", options: [ { - label: "Child", + label: "Child (0-10)", value: "0-9", }, { - label: "Teen", + label: "Teen (10-20)", value: "10-20", }, { - label: "Adult", + label: "Adult (21+)", value: "21-100", }, ], @@ -36,6 +38,7 @@ const questions: Question[] = [ { for: "platforms", header: "Desired Platforms", + question: "What platform(s) does the resource need to be on?", options: [ { label: "Apple (iOS)", @@ -58,6 +61,7 @@ const questions: Question[] = [ { for: "skill_levels", header: "Skill Level", + question: "What skill level(s) should the resource have?", options: [ { label: "Beginner", @@ -76,6 +80,7 @@ const questions: Question[] = [ { for: "skills", header: "Skills Practiced", + question: "What skill(s) would you like the resource to cover?", options: [ { label: "Phonemes", @@ -128,7 +133,7 @@ const ChoiceQuestion = ({question, formData, updateFormData}: {question: Questio } return ( - ) @@ -153,11 +158,12 @@ const ChoiceQuestion = ({question, formData, updateFormData}: {question: Questio return (
- + +

{question.question}

-
+
{optionButtons}
diff --git a/src/server/api/routers/auditoryResources.ts b/src/server/api/routers/auditoryResources.ts index 55be14e..df88620 100644 --- a/src/server/api/routers/auditoryResources.ts +++ b/src/server/api/routers/auditoryResources.ts @@ -36,12 +36,28 @@ export const auditoryResourceRouter = createTRPCRouter({ return ctx.prisma.auditoryResource.findMany({ where: { - // ages: input.ages ? {min: 0, max: 100}, TODO: Make this so ranges work. + ages: { + is: { + min: { + lte: input.ages?.min, + }, + max: { + gte: input.ages?.max, + } + } + }, skill_levels: { hasEvery: input.skill_levels ?? [], }, skills: { hasEvery: input.skills ?? [], + }, + platform_links: { + some: { + platform: { + in: input.platforms, + } + } } } })