Skip to content

Commit

Permalink
Merge pull request #300 from wizeline/feat/298/dont-show-inactive-uni…
Browse files Browse the repository at this point in the history
…versities

feat/298/dont-show-inactive-universities
  • Loading branch information
martinrobled0 authored Jan 10, 2024
2 parents f513ed3 + 5616be8 commit 8fb31fc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/models/university.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
6 changes: 3 additions & 3 deletions app/routes/applicationForm/$applicantId/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -101,7 +101,7 @@ type UserProfile = {
};

type LoaderData = {
universities: Awaited<ReturnType<typeof getUniversities>>;
universities: Awaited<ReturnType<typeof geActivetUniversities>>;
profile: UserProfile;
};

Expand All @@ -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<LoaderData>({
Expand Down

0 comments on commit 8fb31fc

Please sign in to comment.