From 5616be866f28a3fdf70705bb18294961c09f61d4 Mon Sep 17 00:00:00 2001 From: Martin Robledo Date: Mon, 8 Jan 2024 14:11:20 -0600 Subject: [PATCH] feat: showing only active universities on application form --- app/models/university.server.ts | 12 ++++++++++++ app/routes/applicationForm/$applicantId/index.tsx | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/university.server.ts b/app/models/university.server.ts index 0319d53c..88afc560 100644 --- a/app/models/university.server.ts +++ b/app/models/university.server.ts @@ -17,6 +17,18 @@ export async function getUniversities() { }); } +export async function geActivetUniversities() { + return await db.universities.findMany({ + select: { id: true, name: true, active: true }, + orderBy: { + name: "asc", + }, + where: { + active: true, + } + }); +} + async function validateUniversity(id: string) { const innovationTier = await db.universities.findFirst({ diff --git a/app/routes/applicationForm/$applicantId/index.tsx b/app/routes/applicationForm/$applicantId/index.tsx index 811a96c2..84c44212 100644 --- a/app/routes/applicationForm/$applicantId/index.tsx +++ b/app/routes/applicationForm/$applicantId/index.tsx @@ -5,7 +5,7 @@ import { z } from "zod"; import { ValidatedForm } from "remix-validated-form"; import { zfd } from "zod-form-data"; import SelectField from '~/core/components/FormFields/SelectField'; -import { getUniversities } from '~/models/university.server'; +import { geActivetUniversities } from '~/models/university.server'; import type { LoaderFunction } from "@remix-run/node"; import { json } from "@remix-run/node"; import { type SubmitOptions, useLoaderData, useFetcher } from "@remix-run/react"; @@ -101,7 +101,7 @@ type UserProfile = { }; type LoaderData = { - universities: Awaited>; + universities: Awaited>; profile: UserProfile; }; @@ -118,7 +118,7 @@ const profileFetcherOptions: SubmitOptions = { export const loader: LoaderFunction = async ({ request }) => { - const universities = await getUniversities(); + const universities = await geActivetUniversities(); const profile = await requireProfile(request); return json({