Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/298/dont-show-inactive-universities #300

Merged
merged 1 commit into from
Jan 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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