Skip to content

Commit

Permalink
admin table
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Dec 3, 2023
1 parent e6c2acb commit c97f23d
Show file tree
Hide file tree
Showing 5 changed files with 861 additions and 15 deletions.
35 changes: 35 additions & 0 deletions apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,41 @@ export function ticketRoutes(fastify: FastifyInstance) {
}
);

// Get all tickets (admin)
fastify.get(
"/api/v1/tickets/all/admin",
async (request: FastifyRequest, reply: FastifyReply) => {
const bearer = request.headers.authorization!.split(" ")[1];
const token = checkToken(bearer);

if (token) {
const tickets = await prisma.ticket.findMany({
orderBy: [
{
createdAt: "desc",
},
],
include: {
client: {
select: { id: true, name: true, number: true },
},
assignedTo: {
select: { id: true, name: true },
},
team: {
select: { id: true, name: true },
},
},
});

reply.send({
tickets: tickets,
sucess: true,
});
}
}
);

// Get all open tickets for a user
fastify.get(
"/api/v1/tickets/user/open",
Expand Down
Loading

0 comments on commit c97f23d

Please sign in to comment.