Skip to content

Commit 615e383

Browse files
AdityaKhatrifrozenhelium
authored andcommitted
fix(dref): Fix type issues in dref forms
1 parent bfcaecf commit 615e383

File tree

9 files changed

+33
-14
lines changed

9 files changed

+33
-14
lines changed

app/src/components/domain/DrefExportModal/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ function DrefExportModal(props: Props) {
101101
is_pga: isPga,
102102
selector: '#pdf-preview-ready',
103103
per_country: undefined,
104-
is_pga: false,
105104
};
106105
},
107106
[

app/src/components/domain/GoSingleFileInput/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ function GoSingleFileInput<T extends NameType>(props: Props<T>) {
9696
onSuccess();
9797
}
9898

99-
if (isDefined(file) && setFileIdToUrlMap) {
99+
if (isDefined(file) && isDefined(id) && setFileIdToUrlMap) {
100100
setFileIdToUrlMap((oldMap) => {
101101
const newMap = {
102102
...oldMap,

app/src/views/AccountMyFormsDref/ActiveDrefTable/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,9 @@ function ActiveDrefTable(props: Props) {
241241
&& !has_final_report
242242
&& unpublished_op_update_count === 0
243243
// NOTE: Adding this to disable updates just for the old imminents
244-
&& (
245-
item.type_of_dref !== DREF_TYPE_IMMINENT
246-
|| (item.type_of_dref === DREF_TYPE_IMMINENT && is_dref_imminent_v2)
244+
&& (item.type_of_dref !== DREF_TYPE_IMMINENT
245+
|| (item.type_of_dref === DREF_TYPE_IMMINENT
246+
&& isDefined(is_dref_imminent_v2))
247247
);
248248

249249
const canCreateFinalReport = !has_final_report

app/src/views/DrefApplicationForm/index.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ export function Component() {
208208

209209
if (
210210
supporting_document_details
211+
&& supporting_document_details.id
211212
&& supporting_document_details.file
212213
) {
213214
newMap[
@@ -217,6 +218,7 @@ export function Component() {
217218

218219
if (
219220
assessment_report_details
221+
&& assessment_report_details.id
220222
&& assessment_report_details.file
221223
) {
222224
newMap[
@@ -226,28 +228,31 @@ export function Component() {
226228

227229
if (
228230
event_map_file
231+
&& event_map_file.id
229232
&& event_map_file.file
230233
) {
231234
newMap[event_map_file.id] = event_map_file.file;
232235
}
233236

234237
if (
235238
cover_image_file
239+
&& cover_image_file.id
236240
&& cover_image_file.file
237241
) {
238242
newMap[cover_image_file.id] = cover_image_file.file;
239243
}
240244

241245
if ((images_file?.length ?? 0) > 0) {
242246
images_file?.forEach((img) => {
243-
if (isDefined(img.file)) {
247+
if (isDefined(img.file) && isDefined(img.id)) {
244248
newMap[img.id] = img.file;
245249
}
246250
});
247251
}
248252

249253
if (
250254
disaster_category_analysis_details
255+
&& disaster_category_analysis_details.id
251256
&& disaster_category_analysis_details.file
252257
) {
253258
newMap[
@@ -257,6 +262,7 @@ export function Component() {
257262

258263
if (
259264
targeting_strategy_support_file_details
265+
&& targeting_strategy_support_file_details.id
260266
&& targeting_strategy_support_file_details.file
261267
) {
262268
newMap[
@@ -265,6 +271,7 @@ export function Component() {
265271
}
266272
if (
267273
scenario_analysis_supporting_document_details
274+
&& scenario_analysis_supporting_document_details.id
268275
&& scenario_analysis_supporting_document_details.file
269276
) {
270277
newMap[
@@ -274,14 +281,19 @@ export function Component() {
274281

275282
if (
276283
contingency_plans_supporting_document_details
284+
&& contingency_plans_supporting_document_details.id
277285
&& contingency_plans_supporting_document_details.file
278286
) {
279287
newMap[
280288
contingency_plans_supporting_document_details.id
281289
] = contingency_plans_supporting_document_details.file;
282290
}
283291

284-
if (budget_file_details && budget_file_details.file) {
292+
if (
293+
budget_file_details
294+
&& budget_file_details.id
295+
&& budget_file_details.file
296+
) {
285297
newMap[budget_file_details.id] = budget_file_details.file;
286298
}
287299

app/src/views/DrefFinalReportForm/Operation/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function Operation(props: Props) {
133133

134134
const onPopulationChange = useCallback((
135135
val: number | undefined,
136-
name: 'men' | 'women' | 'girls' | 'boys',
136+
name: 'assisted_num_of_women' | 'assisted_num_of_men' | 'assisted_num_of_girls_under_18' | 'assisted_num_of_boys_under_18',
137137
) => {
138138
setValue(
139139
(oldValue: PartialFinalReport | undefined) => {

app/src/views/DrefFinalReportForm/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ export function Component() {
142142
};
143143
if (
144144
response.assessment_report_details
145+
&& response.assessment_report_details.id
145146
&& response.assessment_report_details.file
146147
) {
147148
newMap[
@@ -150,19 +151,22 @@ export function Component() {
150151
}
151152
if (
152153
response.event_map_file
154+
&& response.event_map_file.id
153155
&& response.event_map_file.file
154156
) {
155157
newMap[response.event_map_file.id] = response.event_map_file.file;
156158
}
157159
if (
158160
response.cover_image_file
161+
&& response.cover_image_file.id
159162
&& response.cover_image_file.file
160163
) {
161164
newMap[response.cover_image_file.id] = response.cover_image_file.file;
162165
}
163166

164167
if (
165168
response.financial_report_details
169+
&& response.financial_report_details.id
166170
&& response.financial_report_details.file
167171
) {
168172
// eslint-disable-next-line max-len
@@ -179,7 +183,7 @@ export function Component() {
179183
*/
180184
if ((response.images_file?.length ?? 0) > 0) {
181185
response.images_file?.forEach((img) => {
182-
if (isDefined(img.file)) {
186+
if (isDefined(img.file) && isDefined(img.id)) {
183187
newMap[img.id] = img.file;
184188
}
185189
});

app/src/views/DrefOperationalUpdateForm/index.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,14 @@ export function Component() {
172172

173173
if (
174174
response.budget_file_details
175+
&& response.budget_file_details.id
175176
&& response.budget_file_details.file
176177
) {
177178
newMap[response.budget_file_details.id] = response.budget_file_details.file;
178179
}
179180
if (
180181
response.assessment_report_details
182+
&& response.assessment_report_details.id
181183
&& response.assessment_report_details.file
182184
) {
183185
newMap[
@@ -186,26 +188,28 @@ export function Component() {
186188
}
187189
if (
188190
response.event_map_file
191+
&& response.event_map_file.id
189192
&& response.event_map_file.file
190193
) {
191194
newMap[response.event_map_file.id] = response.event_map_file.file;
192195
}
193196
if (
194197
response.cover_image_file
198+
&& response.cover_image_file.id
195199
&& response.cover_image_file.file
196200
) {
197201
newMap[response.cover_image_file.id] = response.cover_image_file.file;
198202
}
199203
if ((response.photos_file?.length ?? 0) > 0) {
200204
response.photos_file?.forEach((img) => {
201-
if (isDefined(img.file)) {
205+
if (isDefined(img.file) && isDefined(img.id)) {
202206
newMap[img.id] = img.file;
203207
}
204208
});
205209
}
206210
if ((response.images_file?.length ?? 0) > 0) {
207211
response.images_file?.forEach((img) => {
208-
if (isDefined(img.file)) {
212+
if (isDefined(img.file) && isDefined(img.id)) {
209213
newMap[img.id] = img.file;
210214
}
211215
});

app/src/views/FieldReportForm/ActionsFields/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ interface Props {
4444
onValueChange: (...entries: EntriesAsList<PartialFormValue>) => void;
4545
value: PartialFormValue;
4646
disabled?: boolean;
47-
externalPartnerOptions: ExternalPartnerOptions;
48-
supportedActivityOptions: SupportedActivityOptions;
47+
externalPartnerOptions: ExternalPartnerOptions | undefined;
48+
supportedActivityOptions: SupportedActivityOptions | undefined;
4949
actionOptions: Record<
5050
OrganizationType,
5151
{ id: number; name?: string | null, category?: CategoryType }[]

app/src/views/Register/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ type FormFields = PartialForm<RegisterRequestBody & { confirm_password: string }
7171

7272
const defaultFormValue: FormFields = {};
7373

74-
type FormSchema = ObjectSchema<FormFields, FormFields, { whitelistedDomains: WhiteListResponse['results'] }>;
74+
type FormSchema = ObjectSchema<FormFields, FormFields, { whitelistedDomains: WhiteListResponse['results'] | undefined }>;
7575
type FormSchemaFields = ReturnType<FormSchema['fields']>
7676

7777
const formSchema: FormSchema = {

0 commit comments

Comments
 (0)