Skip to content

Commit

Permalink
chore: improved citizen logs
Browse files Browse the repository at this point in the history
  • Loading branch information
casperiv0 committed Oct 16, 2023
1 parent d91638a commit 3dfeb73
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class AdminManageCitizensController {
return { citizens, totalCount };
}

@Get("/pending-arrest-reports")
@Get("/pending-citizen-records")
@Description("Get all the record logs within the CAD")
@UsePermissions({
permissions: [
Expand All @@ -85,11 +85,11 @@ export class AdminManageCitizensController {
Permissions.ViewCitizenLogs,
],
})
async getPendingArrestReports(
async getPendingCitizenRecords(
@QueryParams("skip", Number) skip = 0,
@QueryParams("includeAll", Boolean) includeAll = false,
): Promise<APITypes.GetManagePendingArrestReports> {
const [totalCount, arrestReports] = await prisma.$transaction([
): Promise<APITypes.GetManagePendingCitizenRecords> {
const [totalCount, pendingCitizenRecords] = await prisma.$transaction([
prisma.recordLog.count({
where: { records: { status: WhitelistStatus.PENDING } },
}),
Expand All @@ -109,7 +109,7 @@ export class AdminManageCitizensController {
}),
]);

return { arrestReports, totalCount };
return { pendingCitizenRecords, totalCount };
}

@Get("/records-logs/:citizenId")
Expand Down Expand Up @@ -146,7 +146,7 @@ export class AdminManageCitizensController {
@UsePermissions({
permissions: [Permissions.ManageCitizens, Permissions.ViewCitizenLogs],
})
async acceptOrDeclineArrestReport(
async acceptOrDeclinePendingCitizenLog(
@PathParams("id") id: string,
@BodyParams("type") type: AcceptDeclineType | null,
): Promise<APITypes.PostCitizenRecordLogsData> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ import { ManageRecordModal } from "../modals/manage-record/manage-record-modal";
import useFetch from "lib/useFetch";
import { ViolationsColumn } from "../ViolationsColumn";
import type {
GetManagePendingArrestReports,
GetManagePendingCitizenRecords,
PostCitizenRecordLogsData,
} from "@snailycad/types/api";
import { useQuery } from "@tanstack/react-query";
import { RecordsCaseNumberColumn } from "../records-case-number-column";
import { RecordsStatsColumn } from "../records-stats-column";

interface Props {
arrestReports: GetManagePendingArrestReports;
pendingCitizenRecords: GetManagePendingCitizenRecords;
}

const TYPE_LABELS = {
Expand All @@ -36,7 +36,7 @@ const TYPE_LABELS = {
[RecordType.WRITTEN_WARNING]: "Written Warning",
};

export function PendingCitizenRecordsTab({ arrestReports }: Props) {
export function PendingCitizenRecordsTab({ pendingCitizenRecords }: Props) {
const [tempRecord, setTempRecord] = React.useState<Record | null>(null);

const { data, isLoading, refetch } = useQuery({
Expand All @@ -54,14 +54,14 @@ export function PendingCitizenRecordsTab({ arrestReports }: Props) {
const asyncTable = useAsyncTable({
getKey: (item) => item.recordId ?? item.warrantId ?? item.id,
fetchOptions: {
onResponse: (data: GetManagePendingArrestReports) => ({
data: data.arrestReports,
onResponse: (data: GetManagePendingCitizenRecords) => ({
data: data.pendingCitizenRecords,
totalCount: data.totalCount,
}),
path: "/admin/manage/pending-arrest-reports",
path: "/admin/manage/pending-citizen-records",
},
totalCount: arrestReports.totalCount,
initialData: arrestReports.arrestReports,
totalCount: pendingCitizenRecords.totalCount,
initialData: pendingCitizenRecords.pendingCitizenRecords,
});

const modalState = useModal();
Expand All @@ -71,7 +71,7 @@ export function PendingCitizenRecordsTab({ arrestReports }: Props) {
const { state, execute } = useFetch();
const tableState = useTableState();

function handleViewClick(item: GetManagePendingArrestReports["arrestReports"][number]) {
function handleViewClick(item: GetManagePendingCitizenRecords["pendingCitizenRecords"][number]) {
setTempRecord(item.records!);

modalState.openModal(ModalIds.ManageRecord, {
Expand Down
10 changes: 5 additions & 5 deletions apps/client/src/pages/officer/supervisor/citizen-logs/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { Title } from "components/shared/Title";
import { Permissions } from "@snailycad/permissions";
import { TabList } from "@snailycad/ui";
import { CitizenLogsTab } from "components/leo/citizen-logs/citizen-logs-tab";
import { PendingCitizenRecordsTab } from "components/leo/citizen-logs/arrest-reports-tab";
import { PendingCitizenRecordsTab } from "components/leo/citizen-logs/pending-citizen-logs-tab";
import { useFeatureEnabled } from "hooks/useFeatureEnabled";
import type { GetManagePendingArrestReports, GetManageRecordLogsData } from "@snailycad/types/api";
import type { GetManagePendingCitizenRecords, GetManageRecordLogsData } from "@snailycad/types/api";

export type CitizenLog = RecordLog & { citizen: Citizen };
interface Props {
citizens: GetManageRecordLogsData;
pendingCitizenRecords: GetManagePendingArrestReports;
pendingCitizenRecords: GetManagePendingCitizenRecords;
}

export default function CitizenLogs(props: Props) {
Expand Down Expand Up @@ -47,7 +47,7 @@ export default function CitizenLogs(props: Props) {
<TabList tabs={TABS}>
<CitizenLogsTab citizens={props.citizens} />
{CITIZEN_RECORD_APPROVAL ? (
<PendingCitizenRecordsTab arrestReports={props.pendingCitizenRecords} />
<PendingCitizenRecordsTab pendingCitizenRecords={props.pendingCitizenRecords} />
) : null}
</TabList>
</Layout>
Expand All @@ -58,7 +58,7 @@ export const getServerSideProps: GetServerSideProps = async ({ req, locale }) =>
const user = await getSessionUser(req);
const [citizens, pendingCitizenRecords] = await requestAll(req, [
["/admin/manage/records-logs", { citizens: [], totalCount: 0 }],
["/admin/manage/pending-arrest-reports", { pendingCitizenRecords: [], totalCount: 0 }],
["/admin/manage/pending-citizen-records", { pendingCitizenRecords: [], totalCount: 0 }],
]);

return {
Expand Down
6 changes: 3 additions & 3 deletions packages/types/src/api/admin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,11 @@ export interface GetManageRecordLogsData {

/**
* @method GET
* @route /admin/manage/citizens/pending-arrest-reports
* @route /admin/manage/citizens/pending-citizen-records
*/
export interface GetManagePendingArrestReports {
export interface GetManagePendingCitizenRecords {
totalCount: number;
arrestReports: GetManageRecordsLogsCitizenData["recordsLogs"];
pendingCitizenRecords: GetManageRecordsLogsCitizenData["recordsLogs"];
}

/**
Expand Down

0 comments on commit 3dfeb73

Please sign in to comment.