diff --git a/backend/db/test-only-migrations/V23.0.0__CE-875.sql b/backend/db/test-only-migrations/V23.0.0__CE-875.sql new file mode 100644 index 000000000..e9f364e6f --- /dev/null +++ b/backend/db/test-only-migrations/V23.0.0__CE-875.sql @@ -0,0 +1,5 @@ +update complaint +set + geo_organization_unit_code = 'QUEENCHA' +where + geo_organization_unit_code = 'DJNG'; \ No newline at end of file diff --git a/backend/src/middleware/maps/automapper-entity-to-dto-maps.ts b/backend/src/middleware/maps/automapper-entity-to-dto-maps.ts index 25d867d93..3eece8d0f 100644 --- a/backend/src/middleware/maps/automapper-entity-to-dto-maps.ts +++ b/backend/src/middleware/maps/automapper-entity-to-dto-maps.ts @@ -45,6 +45,10 @@ const cosGeoOrgUnitToOrganizationDtoMap = (mapper: Mapper) => { (destination) => destination.area, mapFrom((source) => source.area_code), ), + forMember( + (destination) => destination.areaName, + mapFrom((source) => source.area_name), + ), forMember( (destination) => destination.officeLocation, mapFrom((source) => source.office_location_code), diff --git a/frontend/src/app/components/containers/complaints/list-items/allegation-complaint-list-item.tsx b/frontend/src/app/components/containers/complaints/list-items/allegation-complaint-list-item.tsx index 41c5d147c..00e094ae0 100644 --- a/frontend/src/app/components/containers/complaints/list-items/allegation-complaint-list-item.tsx +++ b/frontend/src/app/components/containers/complaints/list-items/allegation-complaint-list-item.tsx @@ -15,7 +15,6 @@ type Props = { }; export const AllegationComplaintListItem: FC = ({ type, complaint }) => { - const areaCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.AREA_CODES)); const statusCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.COMPLAINT_STATUS)); const violationCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.VIOLATIONS)); @@ -35,14 +34,9 @@ export const AllegationComplaintListItem: FC = ({ type, complaint }) => { locationDetail, locationSummary, delegates, - organization: { area: locationCode, zone }, + organization: { areaName: location, zone }, } = complaint; - const getLocationName = (input: string): string => { - const code = areaCodes.find((item) => item.area === input); - return code.areaName; - }; - const getStatusDescription = (input: string): string => { const code = statusCodes.find((item) => item.complaintStatus === input); return code.longDescription; @@ -88,8 +82,6 @@ export const AllegationComplaintListItem: FC = ({ type, complaint }) => { const reportedOnDateTime = formatDateTime(reportedOn.toString()); const updatedOnDateTime = formatDateTime(updatedOn.toString()); - const location = getLocationName(locationCode); - const statusButtonClass = `badge ${applyStatusClass(status)}`; const inProgressFlag = isInProgress ? "In Progress" : ""; diff --git a/frontend/src/app/components/containers/complaints/list-items/wildlife-complaint-list-item.tsx b/frontend/src/app/components/containers/complaints/list-items/wildlife-complaint-list-item.tsx index 324a99cb4..b15db4a36 100644 --- a/frontend/src/app/components/containers/complaints/list-items/wildlife-complaint-list-item.tsx +++ b/frontend/src/app/components/containers/complaints/list-items/wildlife-complaint-list-item.tsx @@ -14,7 +14,6 @@ type Props = { }; export const WildlifeComplaintListItem: FC = ({ type, complaint }) => { - const areaCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.AREA_CODES)); const statusCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.COMPLAINT_STATUS)); const natureOfComplaints = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.NATURE_OF_COMPLAINT)); const speciesCodes = useAppSelector(selectCodeTable(CODE_TABLE_TYPES.SPECIES)); @@ -35,14 +34,9 @@ export const WildlifeComplaintListItem: FC = ({ type, complaint }) => { locationDetail, locationSummary, delegates, - organization: { area: locationCode, zone }, + organization: { areaName: location, zone }, } = complaint; - const getLocationName = (input: string): string => { - const code = areaCodes.find((item) => item.area === input); - return code.areaName; - }; - const getStatusDescription = (input: string): string => { const code = statusCodes.find((item) => item.complaintStatus === input); return code.longDescription; @@ -93,8 +87,6 @@ export const WildlifeComplaintListItem: FC = ({ type, complaint }) => { const natureCode = getNatureOfComplaint(natureOfComplaint); const species = getSpecies(speciesCode); - const location = getLocationName(locationCode); - const statusButtonClass = `badge ${applyStatusClass(status)}`; const toggleExpand = () => { diff --git a/frontend/src/app/types/app/complaints/complaint.ts b/frontend/src/app/types/app/complaints/complaint.ts index f5e3a9ae3..739ca7a0d 100644 --- a/frontend/src/app/types/app/complaints/complaint.ts +++ b/frontend/src/app/types/app/complaints/complaint.ts @@ -23,6 +23,7 @@ export interface Complaint { updatedBy: string; organization: { area: string; + areaName?: string; zone: string; region: string; officeLocation?: string;