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

Commit

Permalink
Release 2.0.8 (#162)
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 authored Apr 28, 2021
2 parents 8eb4495 + cf0ca80 commit c3cefa1
Show file tree
Hide file tree
Showing 54 changed files with 960 additions and 111 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# builds
# builds
dist
build
.next
Expand All @@ -16,14 +16,16 @@ src/config.ts

public/citizen-images/*
public/bleeter-images/*
public/mugshots/*
!public/bleeter-images/.gitkeep
!public/citizen-images/.gitkeep
!public/citizen-images/default.svg
!public/mugshots/.gitkeep

.DS_Store

.eslintcache

.vscode

data.json
data.json
8 changes: 8 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

**If you need help updating/installing or have found any bugs, please join [our Discord server](https://discord.gg/eGnrPqEH7U) or open a [GitHub issue here](https://github.com/Dev-CasperTheGhost/snaily-cadv3/issues/new/choose)**

## 2.0.8

- New: able to suspend an officer
- New: able to upload mugshots
- New: added `Jail time` to penal codes
- New: added `Fine Amount` to penal codes
- Minor: minor code changes

## 2.0.7

- New: link officer with citizen
Expand Down
20 changes: 18 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "snaily-cadv3",
"version": "2.0.7",
"version": "2.0.8",
"description": "An open source Computer Aided Dispatch (CAD) for FiveM, this is a web based integration for communities who love police roleplaying and dispatching. ",
"main": "index.js",
"scripts": {
Expand All @@ -26,6 +26,7 @@
},
"homepage": "https://github.com/Dev-CasperTheGhost/snaily-cadv3#readme",
"dependencies": {
"@casper124578/useful": "^0.0.7",
"axios": "^0.21.1",
"bcryptjs": "^2.4.3",
"concurrently": "^6.0.2",
Expand Down
Empty file added public/mugshots/.gitkeep
Empty file.
13 changes: 13 additions & 0 deletions scripts/generate-lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ const ProbablyNotInTheTranslateFile = {
firearms_involved: "Firearm(s) Involved",
deleted_incident: "Successfully deleted incident",
officer_linked_to_citizen: "Officer linked to citizen?",
select_mugshot_files: "Select mugshot files",
upload_mugshots: "Upload mugshots",
mugshots: "Mugshots",
delete_current_mugshot: "Delete current mugshot",
delete_mugshot_success: "Successfully deleted mugshot",
no_mugshots: "This citizen doesn't have any mugshots",
suspend: "Suspend",
revoke: "Revoke",
},
admin: {
...file.admin,
Expand Down Expand Up @@ -212,6 +220,11 @@ const ProbablyNotInTheTranslateFile = {
updated_10_code: "Successfully updated 10 code",
success_penal_code: "Successfully added penal code",
updated_penal_code: "Successfully updated 10 code",
jail_time: "Jail time in seconds (Optional)",
jail_time2: "Jail time",
seconds: "Seconds",
fine_amount: "Fine amount (Optional)",
fine_amount2: "Fine Amount",
},
dispatch: {
...file.dispatch,
Expand Down
14 changes: 14 additions & 0 deletions snaily-cad.sql
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,20 @@ CREATE TABLE `medical_records` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- --------------------------------------------------------
--
-- Table structure for table `mugshots`
--

CREATE TABLE `mugshots` (
`id` varchar(255) NOT NULL,
`citizen_id` varchar(255) NOT NULL,
`data` text NOT NULL DEFAULT '[]',
`officer_name` varchar(255) NOT NULL,
`full_date` text NOT NULL,
`officer_id` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-- --------------------------------------------------------

--
-- Table structure for table `notifications`
Expand Down
4 changes: 2 additions & 2 deletions src/components/GlobalSearch/GlobalSearch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import * as React from "react";
import ReactDOM from "react-dom";
import { connect } from "react-redux";
import Link from "next/link";
import { usePortal } from "@casper124578/useful/hooks/usePortal";
import { Options, useHotkeys } from "react-hotkeys-hook";
import { Items } from "./items";
import { Nullable, State } from "types/State";
import { User } from "types/User";
import { usePortal } from "@hooks/usePortal";
import { useModalOpen } from "@hooks/useModalOpen";
import { ModalIds } from "types/ModalIds";

Expand All @@ -24,7 +24,7 @@ const GlobalSearchC: React.FC<Props> = ({ user }) => {
const [search, setSearch] = React.useState("");

const inputRef = useModalOpen<HTMLInputElement>("globalSearch" as ModalIds);
const ref = usePortal("GlobalSearch");
const ref = usePortal("React_Portal_GlobalSearch");
const filteredItems = React.useMemo(() => {
return Items.filter((item) => item.query.join(" ").includes(search.toLowerCase()));
}, [search]);
Expand Down
8 changes: 5 additions & 3 deletions src/components/Modal/Modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import * as React from "react";
import ReactDOM from "react-dom";
import { modal } from "@lib/utils";
import { ModalIds } from "types/ModalIds";
import { usePortal } from "@hooks/usePortal";
import { usePortal } from "@casper124578/useful/hooks/usePortal";

interface Props {
id: ModalIds;
title: string;
size?: "sm" | "lg" | "xl";
styles?: React.CSSProperties;
}

export const Modal: React.FC<Props> = ({ id, size, title, children }) => {
const portal = usePortal(id);
export const Modal: React.FC<Props> = ({ styles, id, size, title, children }) => {
const portal = usePortal(`Modal_Portal_${id}`);
const [mounted, setMounted] = React.useState(false);

React.useEffect(() => {
Expand All @@ -26,6 +27,7 @@ export const Modal: React.FC<Props> = ({ id, size, title, children }) => {
tabIndex={-1}
aria-labelledby={`${id}-label`}
aria-hidden="true"
style={styles}
>
<div className={`modal-dialog modal-${size} modal-dialog-centered`}>
<div className="modal-content bg-dark border-dark">
Expand Down
29 changes: 29 additions & 0 deletions src/components/modals/admin/penal-codes/CreatePenalCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface Props {
const CreatePenalCodeModalC: React.FC<Props> = ({ addPenalCode }) => {
const [title, setTitle] = React.useState("");
const [des, setDes] = React.useState("");
const [jailTime, setJailTime] = React.useState("");
const [fineAmount, setFineAmount] = React.useState("");
const ref = useModalOpen<HTMLInputElement>(ModalIds.CreatePenalCode);

async function onSubmit(e: React.FormEvent) {
Expand All @@ -23,11 +25,15 @@ const CreatePenalCodeModalC: React.FC<Props> = ({ addPenalCode }) => {
const added = await addPenalCode({
title,
des,
jail_time: jailTime,
fine_amount: fineAmount,
});

if (added === true) {
setTitle("");
setDes("");
setJailTime("");
setFineAmount("");
modal(ModalIds.CreatePenalCode)?.hide();
}
}
Expand All @@ -48,6 +54,29 @@ const CreatePenalCodeModalC: React.FC<Props> = ({ addPenalCode }) => {
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="add_jail_time">
{lang.codes.jail_time}
</label>
<input
id="add_jail_time"
value={jailTime}
onChange={(e) => setJailTime(e.currentTarget.value)}
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="fine_amount">
{lang.codes.fine_amount}
</label>
<input
type="number"
id="fine_amount"
value={fineAmount}
onChange={(e) => setFineAmount(e.currentTarget.value)}
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="code">
{lang.global.description}
Expand Down
30 changes: 30 additions & 0 deletions src/components/modals/admin/penal-codes/EditPenalCodeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@ interface Props {
const EditPenalCodeC: React.FC<Props> = ({ updatePenalCode, code }) => {
const [title, setTitle] = React.useState("");
const [des, setDes] = React.useState<string>("");
const [fineAmount, setFineAmount] = React.useState("");
const [jailTime, setJailTime] = React.useState("");
const ref = useModalOpen<HTMLInputElement>(ModalIds.EditPenalCode);

React.useEffect(() => {
if (!code) return;

setTitle(code?.title);
setDes(code?.des);
setJailTime(code.jail_time ?? "");
setFineAmount(code.fine_amount ?? "");
}, [code]);

async function onSubmit(e: React.FormEvent) {
Expand All @@ -32,6 +36,8 @@ const EditPenalCodeC: React.FC<Props> = ({ updatePenalCode, code }) => {
const updated = await updatePenalCode(code?.id, {
title,
des,
jail_time: jailTime,
fine_amount: fineAmount,
});

if (updated === true) {
Expand All @@ -55,6 +61,30 @@ const EditPenalCodeC: React.FC<Props> = ({ updatePenalCode, code }) => {
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="code">
{lang.codes.jail_time}
</label>
<input
type="number"
id="add_jail_time"
value={jailTime}
onChange={(e) => setJailTime(e.currentTarget.value)}
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="fine_amount">
{lang.codes.fine_amount}
</label>
<input
type="number"
id="fine_amount"
value={fineAmount}
onChange={(e) => setFineAmount(e.currentTarget.value)}
className="form-control bg-secondary border-secondary text-light"
/>
</div>
<div className="mb-3">
<label className="form-label" htmlFor="code">
{lang.global.description}
Expand Down
26 changes: 24 additions & 2 deletions src/components/modals/leo/CreateArrestReportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { Officer } from "types/Officer";
import { Select, SelectValue } from "@components/Select/Select";
import { PenalCode } from "types/PenalCode";
import { ModalIds } from "types/ModalIds";
import { modal } from "@lib/utils";
import { getTotalJailTimeAndFineAmount, modal } from "@lib/utils";
import { ArrestReport } from "types/Record";
import { Name } from "@actions/officer/OfficerTypes";
import { Item, Span } from "@components/Item";

interface Props {
officer: Officer | null;
Expand All @@ -30,10 +31,17 @@ const CreateArrestReportModalC: React.FC<Props> = ({
creatArrestReport,
}) => {
const [name, setName] = React.useState<SelectValue | null>(null);
const [charges, setCharges] = React.useState([]);
const [charges, setCharges] = React.useState<SelectValue[]>([]);
const [postal, setPostal] = React.useState("");
const [notes, setNotes] = React.useState("");
const [loading, setLoading] = React.useState(false);
const { fineAmount, jailTime } = React.useMemo(() => {
const codes = charges.map(
(c) => penalCodes.find((v) => v.title === c.value) ?? ({} as PenalCode),
);

return getTotalJailTimeAndFineAmount(codes);
}, [charges, penalCodes]);

async function onSubmit(e: React.FormEvent) {
e.preventDefault();
Expand Down Expand Up @@ -129,6 +137,20 @@ const CreateArrestReportModalC: React.FC<Props> = ({
</div>

<div className="modal-footer">
{jailTime ? (
<Item className="mx-0">
<>
<Span>{lang.codes.jail_time2}: </Span> {jailTime} {lang.codes.seconds}
</>
</Item>
) : null}
{fineAmount ? (
<Item className="mx-5">
<>
<Span>{lang.codes.fine_amount2}: </Span> {fineAmount}
</>
</Item>
) : null}
<button type="button" className="btn btn-secondary" data-bs-dismiss="modal">
{lang.global.cancel}
</button>
Expand Down
Loading

0 comments on commit c3cefa1

Please sign in to comment.