Skip to content

Commit

Permalink
feat: Support for K9 and less lethal equipment
Browse files Browse the repository at this point in the history
  • Loading branch information
afwilcox committed Jan 2, 2025
1 parent d866c43 commit 593d5ca
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
className="comp-details-form-row"
id="equipment-officer-set-div"
>
<label htmlFor="equipment-officer-set-select">Set by</label>
<label htmlFor="equipment-officer-set-select">Set/Used by</label>
<div className="comp-details-input full-width">
<CompSelect
id="equipment-officer-set-select"
Expand All @@ -417,7 +417,7 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
className="comp-details-form-row"
id="equipment-date-set-div"
>
<label htmlFor="equipment-day-set">Set date</label>
<label htmlFor="equipment-day-set">Set/Used date</label>
<div className="comp-details-input">
<ValidationDatePicker
id="equipment-day-set"
Expand All @@ -433,7 +433,7 @@ export const EquipmentForm: FC<EquipmentFormProps> = ({ equipment, assignedOffic
</div>

{/* REMOVED BY */}
{officerSet && dateSet && (
{officerSet && dateSet && type?.value !== "K9UNT" && type?.value !== "LLTHL" && (
<>
<div
className="comp-details-form-row"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const EquipmentItem: FC<EquipmentItemProps> = ({ equipment, isEditDisable
confirmText="Yes, delete equipment"
/>
<Card
className={`comp-equipment-card ${!removedEquipmentFullName ? "active" : "inactive"}`}
className={`comp-equipment-card ${!removedEquipmentFullName && equipment.typeCode !== "K9UNT" && equipment.typeCode !== "LLTHL" ? "active" : "inactive"}`}
border={showSectionErrors ? "danger" : "default"}
>
<Card.Body>
Expand All @@ -103,7 +103,9 @@ export const EquipmentItem: FC<EquipmentItemProps> = ({ equipment, isEditDisable
<div className="comp-equipment-item-header">
<div className="comp-equipment-item-header-title">
<h4 id="equipment-type-title">{getValue("equipment")?.label}</h4>
{!removedEquipmentFullName && <Badge bg="success">Active</Badge>}
{!removedEquipmentFullName && equipment.typeCode !== "K9UNT" && equipment.typeCode !== "LLTHL" && (
<Badge bg="success">Active</Badge>
)}
</div>
<div className="comp-equipment-item-header-actions">
<Button
Expand Down Expand Up @@ -141,29 +143,32 @@ export const EquipmentItem: FC<EquipmentItemProps> = ({ equipment, isEditDisable
/>
<br />
<div>
<dt>Set by</dt>
<dt>Set/Used by</dt>
<dd>
<span id="equipment-officer-set-div">{setEquipmentFullName}</span>
</dd>
</div>
<div>
<dt>Date set</dt>
<dt>Date set/used</dt>
<dd id="equipment-date-set-div">{formatDate(setEquipmentDate?.toString())}</dd>
</div>
{equipment.id && removedEquipmentActor && (
<>
<div>
<dt>Removed by</dt>
<dd>
<span id="comp-details-assigned-officer-name-text-id">{removedEquipmentFullName}</span>
</dd>
</div>
<div>
<dt>Removal date</dt>
<dd id="equipment-removal-date">{formatDate(removedEquipmentDate?.toString())}</dd>
</div>
</>
)}
{equipment.id &&
removedEquipmentActor &&
equipment.typeCode !== "K9UNT" &&
equipment.typeCode !== "LLTHL" && (
<>
<div>
<dt>Removed by</dt>
<dd>
<span id="comp-details-assigned-officer-name-text-id">{removedEquipmentFullName}</span>
</dd>
</div>
<div>
<dt>Removal date</dt>
<dd id="equipment-removal-date">{formatDate(removedEquipmentDate?.toString())}</dd>
</div>
</>
)}
{equipment.id && ["Y", "N"].includes(equipment?.wasAnimalCaptured) && (
<div>
<dt>Was animal captured?</dt>
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/app/store/reducers/code-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1394,7 +1394,13 @@ export const selectEquipmentDropdown = (state: RootState): Array<Option> => {
codeTables: { equipment: items },
} = state;

const data = items.map(({ equipment: value, shortDescription: label }) => {
// Filter items where active_ind is true and sort them based on display order
const filteredAndSortedItems = items
.filter((item) => item.isActive === true) // Only items with active_ind = true
.sort((a, b) => (a.displayOrder ?? 0) - (b.displayOrder ?? 0)); // Sort by display order assume undefined goes to the beginning

// Map the filtered and sorted items to the Option format
const data = filteredAndSortedItems.map(({ equipment: value, shortDescription: label }) => {
const item: Option = { label, value };
return item;
});
Expand Down

0 comments on commit 593d5ca

Please sign in to comment.