Skip to content
This repository has been archived by the owner on Jan 12, 2022. It is now read-only.

Commit

Permalink
🔨 chore: bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Feb 3, 2021
1 parent f7d7de9 commit c08044e
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 37 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 1.2.1

- Updated db checker to update tables in database
- Fixed typo in name search
- Removed `officer name` from few modals, replaced with current active officer

## 1.2.0

- New revamped select input for selecting assigned units in update 911 call
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/active-911-calls/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ const Active911Calls: React.FC<Props> = ({ calls, getActive911Calls }) => {
getActive911Calls();
});

console.log(location);

socket.on("NEW_911_CALL", () => {
if (["/dispatch", "/leo/dash", "/ems/dash"].includes(location.pathname)) {
playSound("/sounds/new-call.mp3");
Expand Down
2 changes: 2 additions & 0 deletions client/src/components/leo/ModalButtons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ const ModalButtons: React.FC<Props> = ({ activeOfficer }) => {
className="btn btn-secondary col-md-2"
data-bs-target={mButton.target}
data-bs-toggle="modal"
disabled={activeOfficer === null}
title={activeOfficer === null ? "Go on-duty before continuing" : mButton.name}
>
{mButton.name}
</button>
Expand Down
16 changes: 5 additions & 11 deletions client/src/components/modals/leo/createArrestReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import Field from "../../../interfaces/Field";
import AlertMessage from "../../alert-message";
import Modal, { XButton } from "../index";
import { creatArrestReport } from "../../../lib/actions/records";
import Officer from "../../../interfaces/Officer";

interface Props {
error: string;
officer: Officer | null;
creatArrestReport: (data: {
name: string;
officer_name: string;
Expand All @@ -18,9 +20,8 @@ interface Props {
}) => void;
}

const CreateArrestReportModal: React.FC<Props> = ({ error, creatArrestReport }) => {
const CreateArrestReportModal: React.FC<Props> = ({ error, officer, creatArrestReport }) => {
const [name, setName] = React.useState("");
const [officerName, setOfficerName] = React.useState("");
const [charges, setCharges] = React.useState("");
const [postal, setPostal] = React.useState("");
const [notes, setNotes] = React.useState("");
Expand All @@ -31,7 +32,7 @@ const CreateArrestReportModal: React.FC<Props> = ({ error, creatArrestReport })

creatArrestReport({
name,
officer_name: officerName,
officer_name: officer?.officer_name!,
charges,
postal,
notes,
Expand All @@ -45,7 +46,6 @@ const CreateArrestReportModal: React.FC<Props> = ({ error, creatArrestReport })
setCharges("");
setPostal("");
setNotes("");
setOfficerName("");

btnRef.current?.click();
}
Expand All @@ -59,13 +59,6 @@ const CreateArrestReportModal: React.FC<Props> = ({ error, creatArrestReport })
onChange: (e) => setName(e.target.value),
value: name,
},
{
type: "text",
id: "arrest_report_officer_name",
label: lang.record.officer_name,
onChange: (e) => setOfficerName(e.target.value),
value: officerName,
},
{
type: "text",
id: "arrest_report_charges",
Expand Down Expand Up @@ -133,6 +126,7 @@ const CreateArrestReportModal: React.FC<Props> = ({ error, creatArrestReport })

const mapToProps = (state: State) => ({
error: state.officers.error,
officer: state.officers.activeOfficer,
});

export default connect(mapToProps, { creatArrestReport })(CreateArrestReportModal);
16 changes: 5 additions & 11 deletions client/src/components/modals/leo/createTicketModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import AlertMessage from "../../alert-message";
import { connect } from "react-redux";
import Modal, { XButton } from "../index";
import { createTicket } from "../../../lib/actions/records";
import Officer from "../../../interfaces/Officer";

interface Props {
error: string;
officer: Officer | null;
createTicket: (data: {
name: string;
officer_name: string;
Expand All @@ -18,9 +20,8 @@ interface Props {
}) => void;
}

const CreateTicketModal: React.FC<Props> = ({ error, createTicket }) => {
const CreateTicketModal: React.FC<Props> = ({ error, officer, createTicket }) => {
const [name, setName] = React.useState("");
const [officerName, setOfficerName] = React.useState("");
const [violations, setViolations] = React.useState("");
const [postal, setPostal] = React.useState("");
const [notes, setNotes] = React.useState("");
Expand All @@ -31,7 +32,7 @@ const CreateTicketModal: React.FC<Props> = ({ error, createTicket }) => {

createTicket({
name,
officer_name: officerName,
officer_name: officer?.officer_name!,
violations,
postal,
notes,
Expand All @@ -45,7 +46,6 @@ const CreateTicketModal: React.FC<Props> = ({ error, createTicket }) => {
setViolations("");
setPostal("");
setNotes("");
setOfficerName("");

btnRef.current?.click();
}
Expand All @@ -59,13 +59,6 @@ const CreateTicketModal: React.FC<Props> = ({ error, createTicket }) => {
onChange: (e) => setName(e.target.value),
value: name,
},
{
type: "text",
id: "ticket_officer_name",
label: lang.record.officer_name,
onChange: (e) => setOfficerName(e.target.value),
value: officerName,
},
{
type: "text",
id: "ticket_violations",
Expand Down Expand Up @@ -133,6 +126,7 @@ const CreateTicketModal: React.FC<Props> = ({ error, createTicket }) => {

const mapToProps = (state: State) => ({
error: state.officers.error,
officer: state.officers.activeOfficer,
});

export default connect(mapToProps, { createTicket })(CreateTicketModal);
16 changes: 5 additions & 11 deletions client/src/components/modals/leo/createWrittenWarningModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ import AlertMessage from "../../alert-message";
import { connect } from "react-redux";
import Modal, { XButton } from "../index";
import { createWrittenWarning } from "../../../lib/actions/records";
import Officer from "../../../interfaces/Officer";

interface Props {
error: string;
officer: Officer | null;
createWrittenWarning: (data: {
name: string;
officer_name: string;
Expand All @@ -18,9 +20,8 @@ interface Props {
}) => void;
}

const CreateWrittenWarningModal: React.FC<Props> = ({ error, createWrittenWarning }) => {
const CreateWrittenWarningModal: React.FC<Props> = ({ error, officer, createWrittenWarning }) => {
const [name, setName] = React.useState("");
const [officerName, setOfficerName] = React.useState("");
const [infractions, setInfractions] = React.useState("");
const [postal, setPostal] = React.useState("");
const [notes, setNotes] = React.useState("");
Expand All @@ -31,7 +32,7 @@ const CreateWrittenWarningModal: React.FC<Props> = ({ error, createWrittenWarnin

createWrittenWarning({
name,
officer_name: officerName,
officer_name: officer?.officer_name!,
infractions,
postal,
notes,
Expand All @@ -45,7 +46,6 @@ const CreateWrittenWarningModal: React.FC<Props> = ({ error, createWrittenWarnin
setInfractions("");
setPostal("");
setNotes("");
setOfficerName("");

btnRef.current?.click();
}
Expand All @@ -59,13 +59,6 @@ const CreateWrittenWarningModal: React.FC<Props> = ({ error, createWrittenWarnin
onChange: (e) => setName(e.target.value),
value: name,
},
{
type: "text",
id: "written_warning_officer_name",
label: lang.record.officer_name,
onChange: (e) => setOfficerName(e.target.value),
value: officerName,
},
{
type: "text",
id: "written_warning_infractions",
Expand Down Expand Up @@ -133,6 +126,7 @@ const CreateWrittenWarningModal: React.FC<Props> = ({ error, createWrittenWarnin

const mapToProps = (state: State) => ({
error: state.officers.error,
officer: state.officers.activeOfficer,
});

export default connect(mapToProps, { createWrittenWarning })(CreateWrittenWarningModal);
10 changes: 9 additions & 1 deletion client/src/components/modals/leo/nameSearchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ const NameSearchModal: React.FC<Props> = ({ search, searchName, saveNote }) => {
<ul style={{ maxHeight: "20rem" }} className="list-group overflow-auto">
{!search.warrants[0] ? (
<li className="list-group-item border-dark text-dark">
{lang.record.no_arr_rep}
{lang.record.no_warrants}
</li>
) : (
search.warrants.map((warrant: Warrant, idx: number) => {
Expand Down Expand Up @@ -493,6 +493,14 @@ const NameSearchModal: React.FC<Props> = ({ search, searchName, saveNote }) => {
</div>

<div className="modal-footer">
<button
type="button"
className="btn btn-danger"
data-bs-target="#createTicketModal"
data-bs-toggle="modal"
>
{lang.global.create_ticket}
</button>
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">
{lang.global.close}
</button>
Expand Down
19 changes: 18 additions & 1 deletion server/src/lib/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,24 @@ async function select1() {
async function updateDb() {
try {
await processQuery(
"ALTER TABLE `citizens` ADD `note` VARCHAR(255) NOT NULL AFTER `b_status`;ALTER TABLE `officers` ADD `callsign` VARCHAR(255) NOT NULL AFTER `officer_dept`;"
`
CREATE TABLE \`court_requests\` (
\`id\` varchar(255) NOT NULL,
\`warrants\` varchar(2500) NOT NULL,
\`arrest_reports\` varchar(2500) NOT NULL,
\`tickets\` varchar(2500) NOT NULL,
\`citizen_id\` varchar(255) NOT NULL,
\`user_id\` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- ------------
--
-- Indexes for table \`court_requests\`
--
ALTER TABLE \`court_requests\`
ADD PRIMARY KEY (\`id\`);
ALTER TABLE \`citizens\` ADD \`note\` VARCHAR(255) NOT NULL AFTER \`b_status\`;ALTER TABLE \`officers\` ADD \`callsign\` VARCHAR(255) NOT NULL AFTER \`officer_dept\`;`
);

// eslint-disable-next-line no-empty
Expand Down

0 comments on commit c08044e

Please sign in to comment.