Skip to content

Commit

Permalink
Merge pull request #181 from rit-sse/167-update-officer-api
Browse files Browse the repository at this point in the history
add more info to officer route
  • Loading branch information
PokeJofeJr4th authored Nov 3, 2024
2 parents ed541fd + b4b58e7 commit da6aa53
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 10 deletions.
26 changes: 21 additions & 5 deletions next/app/api/officer/[active]/route.ts
Original file line number Diff line number Diff line change
@@ -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)
}
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);
}
28 changes: 23 additions & 5 deletions next/app/api/officer/route.ts
Original file line number Diff line number Diff line change
@@ -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)
}
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);
}

0 comments on commit da6aa53

Please sign in to comment.