From b4b58e7a59a702e577a911e346eede1eb1910d70 Mon Sep 17 00:00:00 2001 From: PokeJofeJr4th Date: Sun, 6 Oct 2024 13:37:48 -0400 Subject: [PATCH] add more info to officer route --- next/app/api/officer/[active]/route.ts | 26 +++++++++++++++++++----- next/app/api/officer/route.ts | 28 +++++++++++++++++++++----- 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/next/app/api/officer/[active]/route.ts b/next/app/api/officer/[active]/route.ts index 53e222f6..17a76a67 100644 --- a/next/app/api/officer/[active]/route.ts +++ b/next/app/api/officer/[active]/route.ts @@ -1,8 +1,24 @@ -import { PrismaClient } from "@prisma/client" +import { PrismaClient } from "@prisma/client"; -const prisma = new PrismaClient() +const prisma = new PrismaClient(); export async function GET() { - const officer = await prisma.officer.findMany({ where: { is_active: true } }) - return Response.json(officer) -} \ No newline at end of file + const officer = await prisma.officer.findMany({ + where: { is_active: true }, + select: { + user: { + select: { + name: true, + email: true, + }, + }, + position: { + select: { + is_primary: true, + title: true, + }, + }, + }, + }); + return Response.json(officer); +} diff --git a/next/app/api/officer/route.ts b/next/app/api/officer/route.ts index adb20945..5f4146f4 100644 --- a/next/app/api/officer/route.ts +++ b/next/app/api/officer/route.ts @@ -1,8 +1,26 @@ -import { PrismaClient } from "@prisma/client" +import { PrismaClient } from "@prisma/client"; -const prisma = new PrismaClient() +const prisma = new PrismaClient(); export async function GET() { - const officer = await prisma.officer.findMany() - return Response.json(officer) -} \ No newline at end of file + const officer = await prisma.officer.findMany({ + select: { + is_active: true, + start_date: true, + end_date: true, + user: { + select: { + name: true, + email: true, + }, + }, + position: { + select: { + is_primary: true, + title: true, + }, + }, + }, + }); + return Response.json(officer); +}