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

Mock incident data #192

Merged
merged 8 commits into from
Oct 15, 2021
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
73 changes: 73 additions & 0 deletions frontend/models/incidents.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { DepartmentType, OfficerRecordType } from "./officer"

/**
* Data to appear in Incidents table
* full record will be superset
*/
export interface IncidentTableData {
id: number
occurred: number // UNIX timestamp
officers: string[] // officer names, "F.Last" (first initial, last name)
incidentType: string
useOfForce: string[]
source: string
}

/**
* Expanded Incident Record
*/
export interface IncidentDetailType extends IncidentTableData {
outcome: string[]
location: string
locationType: string
locationGeo: number[]
summary: string
deptsInvolved: Array<DepartmentType>
officersInvolved: Array<OfficerRecordType>
incidentReportLink: string
passportItems: string[]
}

// Incident Table Data
export const incidentsColumns = [
{
Header: "Date/Time",
accessor: (row: any) => formatDate(row["occurred"]),
id: "occurred"
},
{
Header: "Officer(s)",
accessor: (row: any) => row["officers"].join(", "),
id: "officers"
},
{
Header: "Incident Type",
accessor: "incidentType"
},
{
Header: "Use of Force",
accessor: (row: any) => row["useOfForce"].join(", "),
id: "useOfForce"
},
{
Header: "Source",
accessor: "source"
},
{
Header: "#",
accessor: "id",
disableSortBy: true
}
]

// convert ["First Last", "First Last"] to ["F.Last, F.Last"]
export const formatOfficerNames = (officerNames: string[]): string => {
const rx = /^(?<first>[A-Z])[a-z]+ (?<last>[A-Za-z]+)/
const oNames = officerNames.map((str) => {
const o = str.match(rx)
return `${o.groups.first}.${o.groups.last}`
})
return oNames.join(", ")
}

export const formatDate = (unixTime: number): string => new Date(unixTime).toLocaleDateString()
Loading