Skip to content

Commit c1da1de

Browse files
COMPENF-459, COMPENF-841, COMPENF-864, COMPENF-860 (#129)
Co-authored-by: afwilcox <[email protected]>
1 parent 99571ef commit c1da1de

File tree

8 files changed

+96
-41
lines changed

8 files changed

+96
-41
lines changed

backend/src/v1/allegation_complaint/allegation_complaint.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,7 @@ export class AllegationComplaintService {
462462
in_progress_ind: updateAllegationComplaintDto.in_progress_ind,
463463
observed_ind: updateAllegationComplaintDto.observed_ind,
464464
violation_code: updateAllegationComplaintDto.violation_code,
465+
suspect_witnesss_dtl_text: updateAllegationComplaintDto.suspect_witnesss_dtl_text,
465466
};
466467
const updatedValue = await this.allegationComplaintsRepository.update(
467468
{ allegation_complaint_guid },

backend/src/v1/attractant_hwcr_xref/attractant_hwcr_xref.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ export class AttractantHwcrXrefService {
9191
queryRunner.manager.update(AttractantHwcrXref, updateAttractantHwcrXrefDto.attractant_hwcr_xref_guid, updateAttractantHwcrXrefDto);
9292
}
9393
}
94-
queryRunner.commitTransaction();
94+
await queryRunner.commitTransaction();
9595
}
9696
catch (err) {
9797
this.logger.error(err);
@@ -100,7 +100,7 @@ export class AttractantHwcrXrefService {
100100
}
101101
finally
102102
{
103-
//await queryRunner.release();
103+
await queryRunner.release();
104104
}
105105
return ;
106106
}

backend/src/v1/complaint/complaint.service.ts

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
1-
import { Injectable, Logger } from '@nestjs/common';
1+
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
22
import { CreateComplaintDto } from './dto/create-complaint.dto';
33
import { UpdateComplaintDto } from './dto/update-complaint.dto';
44
import { Complaint } from './entities/complaint.entity';
5-
import { QueryRunner, Repository } from 'typeorm';
5+
import { DataSource, QueryRunner, Repository } from 'typeorm';
66
import { InjectRepository } from '@nestjs/typeorm';
77

88
@Injectable()
99
export class ComplaintService {
10-
10+
11+
constructor(private dataSource: DataSource) {}
1112
private readonly logger = new Logger(ComplaintService.name);
1213

13-
constructor(
14-
) {}
15-
1614

1715
@InjectRepository(Complaint)
1816
private complaintsRepository: Repository<Complaint>;
@@ -50,29 +48,40 @@ export class ComplaintService {
5048
}
5149

5250
async updateComplex(complaint_identifier: string, updateComplaint: string): Promise<Complaint> {
53-
const updateComplaintDto: UpdateComplaintDto = JSON.parse(updateComplaint);
54-
const updateData =
51+
try
52+
{
53+
const updateComplaintDto: UpdateComplaintDto = JSON.parse(updateComplaint);
54+
let referredByAgencyCode = updateComplaintDto.referred_by_agency_code;
55+
if(referredByAgencyCode !== null && referredByAgencyCode.agency_code === "")
5556
{
56-
complaint_status_code: updateComplaintDto.complaint_status_code,
57-
detail_text: updateComplaintDto.detail_text,
58-
location_detailed_text: updateComplaintDto.location_detailed_text,
59-
cos_geo_org_unit: updateComplaintDto.cos_geo_org_unit,
60-
incident_datetime: updateComplaintDto.incident_datetime,
61-
location_geometry_point: updateComplaintDto.location_geometry_point,
62-
location_summary_text: updateComplaintDto.location_summary_text,
63-
caller_name: updateComplaintDto.caller_name,
64-
caller_email: updateComplaintDto.caller_email,
65-
caller_address: updateComplaintDto.caller_address,
66-
caller_phone_1: updateComplaintDto.caller_phone_1,
67-
caller_phone_2: updateComplaintDto.caller_phone_2,
68-
caller_phone_3: updateComplaintDto.caller_phone_3,
69-
referred_by_agency_code: updateComplaintDto.referred_by_agency_code,
70-
};
71-
const updatedValue = await this.complaintsRepository.update(
72-
{ complaint_identifier },
73-
updateData
74-
);
75-
//queryRunner.manager.save(updatedValue);
57+
referredByAgencyCode = null;
58+
}
59+
const updateData =
60+
{
61+
complaint_status_code: updateComplaintDto.complaint_status_code,
62+
detail_text: updateComplaintDto.detail_text,
63+
location_detailed_text: updateComplaintDto.location_detailed_text,
64+
cos_geo_org_unit: updateComplaintDto.cos_geo_org_unit,
65+
incident_datetime: updateComplaintDto.incident_datetime,
66+
location_geometry_point: updateComplaintDto.location_geometry_point,
67+
location_summary_text: updateComplaintDto.location_summary_text,
68+
caller_name: updateComplaintDto.caller_name,
69+
caller_email: updateComplaintDto.caller_email,
70+
caller_address: updateComplaintDto.caller_address,
71+
caller_phone_1: updateComplaintDto.caller_phone_1,
72+
caller_phone_2: updateComplaintDto.caller_phone_2,
73+
caller_phone_3: updateComplaintDto.caller_phone_3,
74+
referred_by_agency_code: referredByAgencyCode,
75+
};
76+
const updatedValue = await this.complaintsRepository.update(
77+
{ complaint_identifier },
78+
updateData
79+
);
80+
}
81+
catch (err) {
82+
this.logger.error(err);
83+
throw new BadRequestException(err);
84+
}
7685
return this.findOne(complaint_identifier);
7786
}
7887

backend/src/v1/person_complaint_xref/person_complaint_xref.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,12 @@ export class PersonComplaintXrefService {
9393
): Promise<PersonComplaintXref> {
9494
this.logger.debug(`Assigning Complaint ${complaintIdentifier}`);
9595
const queryRunner = this.dataSource.createQueryRunner();
96+
let newPersonComplaintXref: PersonComplaintXref;
97+
let unassignedPersonComplaintXref: PersonComplaintXref;
9698

9799
await queryRunner.connect();
98100
await queryRunner.startTransaction();
99-
let newPersonComplaintXref: PersonComplaintXref;
100-
let unassignedPersonComplaintXref: PersonComplaintXref;
101+
101102
try {
102103
// unassign complaint if it's already assigned to an officer
103104
unassignedPersonComplaintXref = await this.findByComplaint(
@@ -110,6 +111,7 @@ export class PersonComplaintXrefService {
110111
unassignedPersonComplaintXref.active_ind = false;
111112
await queryRunner.manager.save(unassignedPersonComplaintXref);
112113
}
114+
this.logger.debug("test9");
113115
// create a new complaint assignment record
114116
newPersonComplaintXref = await this.create(createPersonComplaintXrefDto);
115117
this.logger.debug(

frontend/src/app/components/containers/complaints/complaint-details.tsx

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { PersonComplaintXref } from "../../../types/complaints/person-complaint-
3030
import { ToastContainer, toast } from 'react-toastify';
3131
import 'react-toastify/dist/ReactToastify.css';
3232
import { Coordinates } from "../../../types/app/coordinate-type";
33+
import { AgencyCode } from "../../../types/code-tables/agency-code";
3334

3435
type ComplaintParams = {
3536
id: string;
@@ -686,13 +687,13 @@ function handleViolationTypeChange(selectedOption: Option | null) {
686687
else
687688
{
688689
setSecondaryPhoneMsg("");
689-
if(value !== undefined && complaintType === COMPLAINT_TYPES.HWCR)
690+
if(complaintType === COMPLAINT_TYPES.HWCR)
690691
{
691692
let hwcrComplaint: HwcrComplaint = cloneDeep(updateComplaint) as HwcrComplaint;
692693
hwcrComplaint.complaint_identifier.caller_phone_2 = (value !== undefined ? value : "");
693694
setUpdateComplaint(hwcrComplaint);
694695
}
695-
else if(value !== undefined && complaintType === COMPLAINT_TYPES.ERS)
696+
else if (complaintType === COMPLAINT_TYPES.ERS)
696697
{
697698
let allegationComplaint: AllegationComplaint = cloneDeep(updateComplaint) as AllegationComplaint;
698699
allegationComplaint.complaint_identifier.caller_phone_2 = (value !== undefined ? value : "");
@@ -756,25 +757,61 @@ function handleViolationTypeChange(selectedOption: Option | null) {
756757
function handleReferredByChange(selectedOption: Option | null) {
757758
if(selectedOption !== null && selectedOption !== undefined)
758759
{
760+
const emptyOption: AgencyCode = {
761+
agency_code: "",
762+
short_description: "",
763+
long_description: "",
764+
display_order: 0,
765+
active_ind: true,
766+
create_user_id: "",
767+
create_timestamp: "",
768+
update_user_id: "",
769+
update_timestamp: "",
770+
};
759771
if(complaintType === COMPLAINT_TYPES.HWCR)
760772
{
761773
let hwcrComplaint: HwcrComplaint = cloneDeep(updateComplaint) as HwcrComplaint;
762-
axios.get(`${config.API_BASE_URL}/v1/agency-code/` + selectedOption.value).then((response) => {
763-
hwcrComplaint.complaint_identifier.referred_by_agency_code = response.data;
774+
if(selectedOption.value !== "")
775+
{
776+
axios.get(`${config.API_BASE_URL}/v1/agency-code/` + selectedOption.value).then((response) => {
777+
hwcrComplaint.complaint_identifier.referred_by_agency_code = response.data;
778+
setUpdateComplaint(hwcrComplaint);
779+
});
780+
}
781+
else
782+
{
783+
hwcrComplaint.complaint_identifier.referred_by_agency_code = emptyOption;
764784
setUpdateComplaint(hwcrComplaint);
765-
});
785+
}
766786
}
767787
else if(complaintType === COMPLAINT_TYPES.ERS)
768788
{
769789
let allegationComplaint: AllegationComplaint = cloneDeep(updateComplaint) as AllegationComplaint;
770-
axios.get(`${config.API_BASE_URL}/v1/agency-code/` + selectedOption.value).then((response) => {
771-
allegationComplaint.complaint_identifier.referred_by_agency_code = response.data;
790+
if(selectedOption.value !== "")
791+
{
792+
axios.get(`${config.API_BASE_URL}/v1/agency-code/` + selectedOption.value).then((response) => {
793+
allegationComplaint.complaint_identifier.referred_by_agency_code = response.data;
794+
setUpdateComplaint(allegationComplaint);
795+
});
796+
}
797+
else
798+
{
799+
allegationComplaint.complaint_identifier.referred_by_agency_code = emptyOption;
772800
setUpdateComplaint(allegationComplaint);
773-
});
801+
}
774802
}
775803
}
776804
}
777805

806+
function handleSuspectDetailsChange(value: string) {
807+
if(complaintType === COMPLAINT_TYPES.ERS)
808+
{
809+
let allegationComplaint: AllegationComplaint = updateComplaint as AllegationComplaint;
810+
allegationComplaint.suspect_witnesss_dtl_text = value;
811+
setUpdateComplaint(allegationComplaint);
812+
}
813+
}
814+
778815
return (
779816

780817
<div className="comp-complaint-details">
@@ -814,6 +851,7 @@ function handleViolationTypeChange(selectedOption: Option | null) {
814851
handleViolationInProgessChange={handleViolationInProgessChange}
815852
handleViolationObservedChange={handleViolationObservedChange}
816853
handleViolationTypeChange={handleViolationTypeChange}
854+
handleSuspectDetailsChange={handleSuspectDetailsChange}
817855
/>
818856
}
819857
{ !readOnly &&

frontend/src/app/components/containers/complaints/details/complaint-details-edit.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ interface ComplaintDetailsProps {
8181
handleViolationInProgessChange: Function,
8282
handleViolationObservedChange: Function,
8383
handleViolationTypeChange: Function,
84+
handleSuspectDetailsChange: Function,
8485
}
8586

8687
export const ComplaintDetailsEdit: FC<ComplaintDetailsProps> = ({
@@ -121,6 +122,7 @@ export const ComplaintDetailsEdit: FC<ComplaintDetailsProps> = ({
121122
handleViolationInProgessChange,
122123
handleViolationObservedChange,
123124
handleViolationTypeChange,
125+
handleSuspectDetailsChange,
124126
}) => {
125127
const {
126128
details,
@@ -784,6 +786,7 @@ export const ComplaintDetailsEdit: FC<ComplaintDetailsProps> = ({
784786
id="complaint-description-textarea-id"
785787
defaultValue={complaint_witness_details}
786788
rows={4}
789+
onChange={e => handleSuspectDetailsChange(e.target.value)}
787790
/>
788791
</div>
789792
</div>

frontend/src/app/store/reducers/code-table.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export const codeTableSlice = createSlice({
4444
return { value, label, description } as CodeTable;
4545
}
4646
);
47+
data.unshift({value: "", label: "", description: ""});
4748
return { ...state, agencyCodes: data };
4849
},
4950
setComplaintStatusCodes: (
@@ -170,6 +171,7 @@ export const fetchCodeTables = (): AppThunk => async (dispatch) => {
170171
dispatch(toggleLoading(true));
171172

172173
try {
174+
console.log(JSON.stringify(agencyCodes));
173175
if (!from(agencyCodes).any()) {
174176
dispatch(fetchAgencyCodes());
175177
}

frontend/src/app/types/complaints/allegation-complaint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface AllegationComplaint {
3838
violation_code: ViolationCode;
3939
in_progress_ind: string | boolean;
4040
observed_ind: boolean;
41-
suspect_witnesss_dtl_text?: string
41+
suspect_witnesss_dtl_text: string;
4242
update_timestamp: string;
4343
allegation_complaint_guid: string
4444
}

0 commit comments

Comments
 (0)