Skip to content

Commit b073b03

Browse files
authored
COMP-508: Save Changes dialog come every time the drawer is opened (#604)
1 parent 5640f62 commit b073b03

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

compliance-web/src/components/App/CaseFiles/CaseFileDrawer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const CaseFileDrawer: React.FC<CaseFileDrawerProps> = ({
8484
if (caseFile) {
8585
return {
8686
project: caseFile.project,
87-
dateCreated: dayjs(caseFile.date_created),
87+
dateCreated: caseFile.date_created ? dayjs(caseFile.date_created) : undefined,
8888
primaryOfficer: caseFile.primary_officer,
8989
officers: caseFile.officers,
9090
initiation: caseFile.initiation,

compliance-web/src/components/App/Complaints/ComplaintDrawer.tsx

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,22 @@ type ComplaintDrawerProps = {
3939
};
4040

4141
const initFormData: ComplaintFormData = {
42-
project: undefined,
43-
dateReceived: undefined,
42+
concernDescription: "",
43+
locationDescription: "",
44+
topic: undefined,
4445
primaryOfficer: undefined,
46+
dateReceived: undefined,
4547
complaintSource: undefined,
48+
contactFullName: "",
49+
contactTitle: "",
50+
contactEmail: "",
51+
contactPhoneNumber: "",
52+
contactComments: "",
53+
agency: undefined,
54+
firstNation: undefined,
55+
otherDescription: "",
4656
requirementSource: undefined,
57+
requirementSourceDescription: "",
4758
order: undefined,
4859
};
4960

@@ -81,7 +92,9 @@ const ComplaintDrawer: React.FC<ComplaintDrawerProps> = ({
8192
locationDescription: complaint.location_description,
8293
primaryOfficer: complaint.primary_officer,
8394
topic: complaint.topic,
84-
dateReceived: dayjs(complaint.date_received),
95+
dateReceived: complaint.date_received
96+
? dayjs(complaint.date_received)
97+
: undefined,
8598
complaintSource: complaint.source_type,
8699
contactFullName: complaint.source_contact.full_name ?? "",
87100
contactTitle: complaint.source_contact.title ?? "",
@@ -105,17 +118,9 @@ const ComplaintDrawer: React.FC<ComplaintDrawerProps> = ({
105118
);
106119
return {
107120
...initFormData,
108-
caseFileId: caseFile.id.toString(),
109121
primaryOfficer: selectedOfficer,
110122
};
111-
}, [
112-
agenciesList,
113-
complaint,
114-
firstNationsList,
115-
caseFile,
116-
staffUserList,
117-
currentUser,
118-
]);
123+
}, [agenciesList, complaint, firstNationsList, staffUserList, currentUser]);
119124

120125
const methods = useForm<ComplaintSchemaType>({
121126
resolver: yupResolver(ComplaintFormSchema),

compliance-web/src/components/App/Inspections/InspectionDrawer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ const InspectionDrawer: React.FC<InspectionDrawerProps> = ({
8787
if (inspection) {
8888
return {
8989
project: inspection.project,
90-
startDate: dayjs(inspection.start_date),
91-
endDate: dayjs(inspection.end_date),
92-
debriefDate: dayjs(inspection.debrief_date),
90+
startDate: inspection.start_date ? dayjs(inspection.start_date) : undefined,
91+
endDate: inspection.end_date ? dayjs(inspection.end_date) : undefined,
92+
debriefDate: inspection.debrief_date ? dayjs(inspection.debrief_date) : undefined,
9393
primaryOfficer: inspection.primary_officer,
9494
initiation: inspection.initiation,
9595
irTypes: inspection.types,

compliance-web/src/components/Shared/Controlled/ControlledDateField.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ const ControlledDateField: FC<IFormDateInputProps> = ({
3232
<Controller
3333
name={name}
3434
control={control}
35-
defaultValue={null}
3635
render={({ field }) => (
3736
<DatePicker
3837
{...field}
3938
label={label}
4039
format={DATE_FORMAT}
40+
value={field.value ?? null}
4141
onChange={(date: Dayjs | null) => {
4242
field.onChange(date);
4343
}}

compliance-web/src/models/Complaint.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,22 @@ export interface ComplaintGridItems {
6767
}
6868

6969
export interface ComplaintFormData {
70-
project?: Project;
71-
dateReceived?: Dayjs;
72-
primaryOfficer?: StaffUser;
7370
concernDescription?: string;
7471
locationDescription?: string;
72+
topic?: Topic;
73+
primaryOfficer?: StaffUser;
74+
dateReceived?: Dayjs;
7575
complaintSource?: ComplaintSource;
76+
contactFullName?: string;
77+
contactTitle?: string;
78+
contactEmail?: string;
79+
contactPhoneNumber?: string;
80+
contactComments?: string;
81+
agency?: Agency;
82+
firstNation?: FirstNation;
83+
otherDescription?: string;
7684
requirementSource?: RequirementSource;
85+
requirementSourceDescription?: string;
7786
order?: InspectionOrder;
7887
}
7988

0 commit comments

Comments
 (0)