Skip to content

Commit b846509

Browse files
committed
fix: show server generated summary field for field report
1 parent f96e177 commit b846509

File tree

3 files changed

+46
-37
lines changed

3 files changed

+46
-37
lines changed

app/src/views/FieldReportForm/ContextFields/i18n.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
"fieldReportFormContextTitle": "Context",
3434
"fieldReportFormSearchTitle": "Search for existing emergency",
3535
"fieldReportFormSearchDescription": "Type the name of the country you want to report on in the box above to begin the search.",
36-
"fieldPrefix": "Prefix",
37-
"fieldReportFormSuffix": "Suffix"
36+
"originalTitleSecondaryLabel": "Original Title"
3837
}
3938
}
4039

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

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
TextInput,
1212
} from '@ifrc-go/ui';
1313
import { useTranslation } from '@ifrc-go/ui/hooks';
14-
import { isNotDefined } from '@togglecorp/fujs';
14+
import {
15+
isNotDefined,
16+
isTruthyString,
17+
} from '@togglecorp/fujs';
1518
import {
1619
type EntriesAsList,
1720
type Error,
@@ -163,11 +166,6 @@ function ContextFields(props: Props) {
163166

164167
const summaryVisible = !value.is_covid_report;
165168

166-
const preferredColumnNoForSummary = Math.max(
167-
summaryVisible ? 1 : 0,
168-
1,
169-
) as 1 | 2 | 3;
170-
171169
return (
172170
<Container
173171
heading={strings.fieldReportFormContextTitle}
@@ -285,20 +283,32 @@ function ContextFields(props: Props) {
285283
title={strings.summaryLabel}
286284
description={strings.summaryDescription}
287285
withAsteriskOnTitle
288-
numPreferredColumns={preferredColumnNoForSummary}
286+
numPreferredColumns={1}
289287
>
290288
{summaryVisible && (
291-
<TextInput
292-
label={strings.titleSecondaryLabel}
293-
placeholder={strings.titleInputPlaceholder}
294-
name="title"
295-
value={value.title}
296-
maxLength={256}
297-
onChange={onValueChange}
298-
error={error?.title}
299-
disabled={disabled}
300-
withAsterisk
301-
/>
289+
<>
290+
<TextInput
291+
label={strings.titleSecondaryLabel}
292+
placeholder={strings.titleInputPlaceholder}
293+
name="title"
294+
value={value.title}
295+
maxLength={256}
296+
onChange={onValueChange}
297+
error={error?.title}
298+
disabled={disabled}
299+
withAsterisk
300+
/>
301+
{isTruthyString(value.summary) && (
302+
<TextInput
303+
label={strings.originalTitleSecondaryLabel}
304+
name="summary"
305+
value={value.summary}
306+
onChange={onValueChange}
307+
error={error?.summary}
308+
disabled
309+
/>
310+
)}
311+
</>
302312
)}
303313
</InputSection>
304314
<InputSection

app/src/views/FieldReportForm/common.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,23 @@ export const reportSchema: FormSchema = {
311311
});
312312

313313
// CONTEXT
314-
// baseSchema = addCondition(
315-
// baseSchema,
316-
// value,
317-
// ['status', 'is_covid_report', 'dtype'],
318-
// ['summary'],
319-
// (val): Pick<FormSchemaFields, 'summary'> => {
320-
// const reportType = getReportType(val?.status, val?.is_covid_report, val?.dtype);
321-
// if (reportType === 'COVID') {
322-
// return {
323-
// summary: { forceValue: nullValue },
324-
// };
325-
// }
326-
// return {
327-
// summary: { required: true, requiredValidation: requiredStringCondition },
328-
// };
329-
// },
330-
// );
314+
baseSchema = addCondition(
315+
baseSchema,
316+
value,
317+
['status', 'is_covid_report', 'dtype'],
318+
['summary'],
319+
(val): Pick<FormSchemaFields, 'summary'> => {
320+
const reportType = getReportType(val?.status, val?.is_covid_report, val?.dtype);
321+
if (reportType === 'COVID') {
322+
return {
323+
summary: { forceValue: nullValue },
324+
};
325+
}
326+
return {
327+
summary: { required: true, requiredValidation: requiredStringCondition },
328+
};
329+
},
330+
);
331331

332332
// SITUATION / RISK ANALYSIS
333333

0 commit comments

Comments
 (0)