diff --git a/apps/api/src/controllers/admin/manage/citizens/records-logs-controller.ts b/apps/api/src/controllers/admin/manage/citizens/records-logs-controller.ts index eb369c837..621719d2f 100644 --- a/apps/api/src/controllers/admin/manage/citizens/records-logs-controller.ts +++ b/apps/api/src/controllers/admin/manage/citizens/records-logs-controller.ts @@ -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: [ @@ -85,11 +85,11 @@ export class AdminManageCitizensController { Permissions.ViewCitizenLogs, ], }) - async getPendingArrestReports( + async getPendingCitizenRecords( @QueryParams("skip", Number) skip = 0, @QueryParams("includeAll", Boolean) includeAll = false, - ): Promise { - const [totalCount, arrestReports] = await prisma.$transaction([ + ): Promise { + const [totalCount, pendingCitizenRecords] = await prisma.$transaction([ prisma.recordLog.count({ where: { records: { status: WhitelistStatus.PENDING } }, }), @@ -109,7 +109,7 @@ export class AdminManageCitizensController { }), ]); - return { arrestReports, totalCount }; + return { pendingCitizenRecords, totalCount }; } @Get("/records-logs/:citizenId") @@ -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 { diff --git a/apps/client/src/components/leo/citizen-logs/arrest-reports-tab.tsx b/apps/client/src/components/leo/citizen-logs/pending-citizen-logs-tab.tsx similarity index 89% rename from apps/client/src/components/leo/citizen-logs/arrest-reports-tab.tsx rename to apps/client/src/components/leo/citizen-logs/pending-citizen-logs-tab.tsx index 06223fa80..3cc56dbb8 100644 --- a/apps/client/src/components/leo/citizen-logs/arrest-reports-tab.tsx +++ b/apps/client/src/components/leo/citizen-logs/pending-citizen-logs-tab.tsx @@ -19,7 +19,7 @@ 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"; @@ -27,7 +27,7 @@ import { RecordsCaseNumberColumn } from "../records-case-number-column"; import { RecordsStatsColumn } from "../records-stats-column"; interface Props { - arrestReports: GetManagePendingArrestReports; + pendingCitizenRecords: GetManagePendingCitizenRecords; } const TYPE_LABELS = { @@ -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(null); const { data, isLoading, refetch } = useQuery({ @@ -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(); @@ -71,7 +71,7 @@ export function PendingCitizenRecordsTab({ arrestReports }: Props) { const { state, execute } = useFetch(); const tableState = useTableState(); - function handleViewClick(item: GetManagePendingArrestReports["arrestReports"][number]) { + function handleEditClick(item: GetManagePendingCitizenRecords["pendingCitizenRecords"][number]) { setTempRecord(item.records!); modalState.openModal(ModalIds.ManageRecord, { @@ -95,6 +95,12 @@ export function PendingCitizenRecordsTab({ arrestReports }: Props) { } } + async function handleRecordUpdate() { + await refetch(); + asyncTable.refetch(); + setTempRecord(null); + } + return ( {record.status}, actions: ( <> -