add all search queries to result set

This commit is contained in:
Brandon Egger 2023-03-17 19:17:33 -05:00
parent 4b03b787c3
commit 2c29d8ae3c
2 changed files with 29 additions and 7 deletions

View File

@ -11,6 +11,7 @@ interface Option<T> {
interface Question<T> { interface Question<T> {
for: string, for: string,
header: string, header: string,
question: string,
options: Option<T>[] options: Option<T>[]
} }
@ -18,17 +19,18 @@ const questions: Question<QuestionTypes>[] = [
{ {
for: "ages", for: "ages",
header: "Age of Patient", header: "Age of Patient",
question: "How old is the patient?",
options: [ options: [
{ {
label: "Child", label: "Child (0-10)",
value: "0-9", value: "0-9",
}, },
{ {
label: "Teen", label: "Teen (10-20)",
value: "10-20", value: "10-20",
}, },
{ {
label: "Adult", label: "Adult (21+)",
value: "21-100", value: "21-100",
}, },
], ],
@ -36,6 +38,7 @@ const questions: Question<QuestionTypes>[] = [
{ {
for: "platforms", for: "platforms",
header: "Desired Platforms", header: "Desired Platforms",
question: "What platform(s) does the resource need to be on?",
options: [ options: [
{ {
label: "Apple (iOS)", label: "Apple (iOS)",
@ -58,6 +61,7 @@ const questions: Question<QuestionTypes>[] = [
{ {
for: "skill_levels", for: "skill_levels",
header: "Skill Level", header: "Skill Level",
question: "What skill level(s) should the resource have?",
options: [ options: [
{ {
label: "Beginner", label: "Beginner",
@ -76,6 +80,7 @@ const questions: Question<QuestionTypes>[] = [
{ {
for: "skills", for: "skills",
header: "Skills Practiced", header: "Skills Practiced",
question: "What skill(s) would you like the resource to cover?",
options: [ options: [
{ {
label: "Phonemes", label: "Phonemes",
@ -128,7 +133,7 @@ const ChoiceQuestion = ({question, formData, updateFormData}: {question: Questio
} }
return ( return (
<button type="button" onClick={handleToggle} className={"w-64 shadow rounded-lg border border-neutral-400 " + (selected ? "bg-amber-200" : "bg-white")}> <button type="button" onClick={handleToggle} className={"mx-auto w-64 py-2 shadow rounded-lg border border-neutral-400 " + (selected ? "bg-amber-200" : "bg-white")}>
{option.label} {option.label}
</button> </button>
) )
@ -153,11 +158,12 @@ const ChoiceQuestion = ({question, formData, updateFormData}: {question: Questio
return ( return (
<div className="text-center border-b border-neutral-400 py-4 mx-auto"> <div className="text-center border-b border-neutral-400 py-4 mx-auto">
<label htmlFor={question.for} className="font-bold text-xl mb-2">{question.header}</label> <label htmlFor={question.for} className="font-bold border-b border-neutral-800 text-xl mb-2">{question.header}</label>
<p className="text-md mb-2">{question.question}</p>
<select className="hidden" name={question.for} multiple> <select className="hidden" name={question.for} multiple>
{htmlOptions} {htmlOptions}
</select> </select>
<div className="flex flex-col"> <div className="flex flex-col space-y-1 justify-center">
{optionButtons} {optionButtons}
</div> </div>
</div> </div>

View File

@ -36,12 +36,28 @@ export const auditoryResourceRouter = createTRPCRouter({
return ctx.prisma.auditoryResource.findMany({ return ctx.prisma.auditoryResource.findMany({
where: { 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: { skill_levels: {
hasEvery: input.skill_levels ?? [], hasEvery: input.skill_levels ?? [],
}, },
skills: { skills: {
hasEvery: input.skills ?? [], hasEvery: input.skills ?? [],
},
platform_links: {
some: {
platform: {
in: input.platforms,
}
}
} }
} }
}) })