Skip to content

Commit

Permalink
Merge branch 'main' of github.com:SnailyCAD/snaily-cadv4 into main
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Apr 3, 2022
2 parents 4e5a350 + a9acd8d commit 927f973
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Controller } from "@tsed/di";
import { Delete, Get, Post, Put } from "@tsed/schema";
import { Delete, Description, Get, Post, Put } from "@tsed/schema";
import { CREATE_911_CALL, LINK_INCIDENT_TO_CALL } from "@snailycad/schemas";
import { HeaderParams, BodyParams, Context, PathParams, QueryParams } from "@tsed/platform-params";
import { BadRequest, NotFound } from "@tsed/exceptions";
Expand Down Expand Up @@ -59,6 +59,7 @@ export class Calls911Controller {
}

@Get("/")
@Description("Get all 911 calls")
async get911Calls(@QueryParams("includeEnded") includeEnded: boolean) {
const calls = await prisma.call911.findMany({
include: callInclude,
Expand All @@ -71,6 +72,21 @@ export class Calls911Controller {
return calls.map(this.officerOrDeputyToUnit);
}

@Get("/:id")
@Description("Get an incident by its id")
@UsePermissions({
permissions: [Permissions.ViewIncidents, Permissions.ManageIncidents],
fallback: (u) => u.isDispatch || u.isLeo,
})
async getIncidentById(@PathParams("id") id: string) {
const call = await prisma.call911.findUnique({
where: { id },
include: callInclude,
});

return this.officerOrDeputyToUnit(call);
}

@Post("/")
async create911Call(
@BodyParams() body: unknown,
Expand Down
15 changes: 15 additions & 0 deletions packages/api/src/controllers/leo/incidents/IncidentController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@ export class IncidentController {
return { incidents, officers };
}

@Get("/:id")
@Description("Get an incident by its id")
@UsePermissions({
permissions: [Permissions.ViewIncidents, Permissions.ManageIncidents],
fallback: (u) => u.isDispatch || u.isLeo,
})
async getIncidentById(@PathParams("id") id: string) {
const incident = await prisma.leoIncident.findUnique({
where: { id },
include: incidentInclude,
});

return incident;
}

@UseBefore(ActiveOfficer)
@Post("/")
@UsePermissions({
Expand Down

0 comments on commit 927f973

Please sign in to comment.