Skip to content

Commit fd41760

Browse files
Comp 646 (#524)
* case file server side pagination and download * case_file, inspection and complaints server side sorting and pagination * lint fixes * lint fixes * COMP-603: Pagination for Inspection + Filter * COMP-604: Download Inspections * base table query modal * COMP-605: Pagination for Complaints * COMP-605: My Files Toggle * COMP-606: Download Complaints * source type and topic filter/sort added in compliance api * COMP-600: Pagination for Case Files * COMP-602: Download Case Files * unit test fixes * sort logic fixes for tables * case file list options endpoint changed (#464) * COMP-618: For Continuation Report, change Date format to YYYY/MM/DD (#466) * multi values for filters for case file, inspection and complaints * case file list options endpoint changed * all filters of major tables made multi * switch filtering fixes * test fix * COMP-620: Complaints not surfaced on Case File profile due to new pagination * unit test fix --------- Co-authored-by: dinesh <dinesh.pb@aot-technologies.com> * complaint, inspection, download issue (#476) * list ordering and indentations fixed and inline styles rendered safely (#474) * list ordering and indentations fixed and inline styles rendered safely * lint fixes * Agencies in ascending order (#501) * Issuing officer change wasn't reflecting in OR and WL (#499) * issuing officer bug in or and wl * staff user testing issue fix * COMP-627: Adding Title to Complaint Sources (front+back) (#505) * COMP-627: Adding Title to Complaint Sources (front+back) * Complaint Resolution (#507) * complaint resolutions table and api added * complaints resolution capturing on close and fetching * Close complaint modal and resolution selection * complaints resolution in table, case file complaints grid, and export * Order Rescind Changes (#508) * order rescind changes * adding migration merge heads * COMP-621: New Rescind Order pup-ups (front) * COMP-632: Label changes * COMP-635: Sorting/filtering bug on Case Files/Inspections etc (#513) * COMP-635: Sorting/filtering bug on Case Files/Inspections etc * my files toggle filter by current logged in user only * filter Open case files during first load * complaints my files changes * code optimization for table handlers * Issuing officer change reflect in wl (#518) * issuing officer bug in or and wl * staff user testing issue fix * issuing officer change reflect in wl * Deletion of OR and WL even if it is in progress (#522) * deletion of wl * deletion of or and wl * enforcement flag component common, added status in the casefile grid * lint fixes --------- Co-authored-by: dinesh <dinesh.pb@aot-technologies.com> Co-authored-by: Dinesh <97143739+dinesh-aot@users.noreply.github.com>
1 parent c4aedc8 commit fd41760

File tree

6 files changed

+170
-94
lines changed

6 files changed

+170
-94
lines changed

compliance-web/src/components/App/CaseFiles/Profile/CaseFileInspectionsTable.tsx

Lines changed: 10 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { useStaffUsersData } from "@/hooks/useStaff";
3737
import { useFetchWarningLetterByNumber } from "@/hooks/useInspectionWarningLetters";
3838
import { InspectionWarningLetter } from "@/models/InspectionWarningLetter";
3939
import WarningLetterDrawer from "@/components/App/Inspections/Profile/Enforcements/WarningLetters/WarningLetterDrawer";
40+
import EnforcementStatusFlag from "@/components/App/Inspections/Profile/Enforcements/EnforcementStatusFlag";
4041

4142
const styleOverFlowClipped = {
4243
whiteSpace: "nowrap",
@@ -54,7 +55,7 @@ const CaseFileInspectionsTable = ({ caseFile }: { caseFile: CaseFile }) => {
5455
return inspectionsListData?.items;
5556
}, [inspectionsListData]);
5657
const { data: staffUsersList } = useStaffUsersData();
57-
58+
5859
const [expandedInspections, setExpandedInspections] = useState<Set<number>>(
5960
new Set()
6061
);
@@ -71,20 +72,6 @@ const CaseFileInspectionsTable = ({ caseFile }: { caseFile: CaseFile }) => {
7172
});
7273
};
7374

74-
const getStatusFlagColor = (progress: { id: string; name: string }) => {
75-
switch (progress.id) {
76-
case OrderProgressEnum.DRAFTING:
77-
return "default";
78-
case OrderProgressEnum.DEPUTY_REVIEW:
79-
return "warning";
80-
case OrderProgressEnum.APPROVED:
81-
case OrderProgressEnum.ISSUED:
82-
return "success";
83-
default:
84-
return "default";
85-
}
86-
};
87-
8875
const isEnforcementActionLink = (
8976
enforcementAction: InspectionMoreDetailsEnforcementAction | undefined
9077
): boolean => {
@@ -366,16 +353,15 @@ const CaseFileInspectionsTable = ({ caseFile }: { caseFile: CaseFile }) => {
366353
)}
367354
</Grid>
368355
<Grid item xs={2}>
369-
{requirement.enforcement_action?.progress && (
370-
<Chip
371-
label={
372-
requirement.enforcement_action?.progress?.name
356+
{requirement.enforcement_action && (
357+
<EnforcementStatusFlag
358+
enforcementActionType={
359+
requirement.enforcement_action
360+
.id as EnforcementActionEnum
361+
}
362+
enforcementActionDetails={
363+
requirement.enforcement_action
373364
}
374-
color={getStatusFlagColor(
375-
requirement.enforcement_action?.progress
376-
)}
377-
variant="outlined"
378-
size="small"
379365
/>
380366
)}
381367
</Grid>

compliance-web/src/components/App/Inspections/Profile/Enforcements/EnforcementCard.tsx

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import { AdministrativePenalty } from "@/models/AdministrativePenalty";
1717
import { ChargeRecommendation } from "@/models/ChargeRecommendation";
1818
import { ViolationTicket } from "@/models/ViolationTicket";
1919
import { RestorativeJustice } from "@/models/RestorativeJustice";
20+
import { useMemo } from "react";
21+
import { EnforcementActionEnum } from "@/utils/constants";
2022

2123
const EnforcementCard = ({
2224
order,
@@ -57,6 +59,28 @@ const EnforcementCard = ({
5759
const approvedByDate = getApprovedByDate(order, warningLetter);
5860
const approverName = getApproverName(order, warningLetter);
5961

62+
const enforcementActionType = useMemo(() => {
63+
if (order) {
64+
return EnforcementActionEnum.ORDER;
65+
} else if (warningLetter) {
66+
return EnforcementActionEnum.WARNING_LETTER;
67+
} else if (administrativePenalty) {
68+
return EnforcementActionEnum.AP_RECOMMENDATION;
69+
} else if (chargeRecommendation) {
70+
return EnforcementActionEnum.CHARGE_RECOMMENDATION;
71+
} else if (violationTicket) {
72+
return EnforcementActionEnum.VIOLATION_TICKET;
73+
} else {
74+
return EnforcementActionEnum.RESTORATIVE_JUSTICE;
75+
}
76+
}, [
77+
administrativePenalty,
78+
chargeRecommendation,
79+
order,
80+
violationTicket,
81+
warningLetter,
82+
]);
83+
6084
return (
6185
<Box
6286
sx={{
@@ -92,6 +116,7 @@ const EnforcementCard = ({
92116
restorativeJustice?.restorative_justice_number}
93117
</Typography>
94118
<EnforcementStatusFlag
119+
enforcementActionType={enforcementActionType}
95120
order={order}
96121
warningLetter={warningLetter}
97122
administrativePenalty={administrativePenalty}
@@ -142,8 +167,8 @@ const EnforcementCard = ({
142167
value={
143168
(order || warningLetter)?.date_issued
144169
? dateUtils.formatDate(
145-
(order || warningLetter)?.date_issued ?? ""
146-
)
170+
(order || warningLetter)?.date_issued ?? ""
171+
)
147172
: ""
148173
}
149174
gridProps={{ xs: 6 }}
@@ -190,7 +215,9 @@ const EnforcementCard = ({
190215
label="Date to Crown Counsel"
191216
value={
192217
chargeRecommendation.date_to_crown_counsel
193-
? dateUtils.formatDate(chargeRecommendation.date_to_crown_counsel)
218+
? dateUtils.formatDate(
219+
chargeRecommendation.date_to_crown_counsel
220+
)
194221
: ""
195222
}
196223
gridProps={{ xs: 6 }}
@@ -209,7 +236,9 @@ const EnforcementCard = ({
209236
label="Charge Decision Date"
210237
value={
211238
chargeRecommendation.charge_decision_date
212-
? dateUtils.formatDate(chargeRecommendation.charge_decision_date)
239+
? dateUtils.formatDate(
240+
chargeRecommendation.charge_decision_date
241+
)
213242
: ""
214243
}
215244
gridProps={{ xs: 6 }}
@@ -273,9 +302,11 @@ const EnforcementCard = ({
273302
/>
274303
<GridLabelValuePair
275304
label="Status Date"
276-
value={violationTicket.status_date
277-
? dateUtils.formatDate(violationTicket.status_date)
278-
: ""}
305+
value={
306+
violationTicket.status_date
307+
? dateUtils.formatDate(violationTicket.status_date)
308+
: ""
309+
}
279310
gridProps={{ xs: 6 }}
280311
/>
281312
</>
@@ -292,7 +323,9 @@ const EnforcementCard = ({
292323
label="Date Restitution Complete"
293324
value={
294325
restorativeJustice.date_restitution_complete
295-
? dateUtils.formatDate(restorativeJustice.date_restitution_complete)
326+
? dateUtils.formatDate(
327+
restorativeJustice.date_restitution_complete
328+
)
296329
: ""
297330
}
298331
gridProps={{ xs: 12 }}

0 commit comments

Comments
 (0)