|
1 | | -function EarlyAction() { |
| 1 | +import { |
| 2 | + Container, |
| 3 | + InputSection, |
| 4 | + TextArea, |
| 5 | + TextInput, |
| 6 | +} from '@ifrc-go/ui'; |
| 7 | +import { useTranslation } from '@ifrc-go/ui/hooks'; |
| 8 | +import { |
| 9 | + type EntriesAsList, |
| 10 | + type Error, |
| 11 | + getErrorObject, |
| 12 | +} from '@togglecorp/toggle-form'; |
| 13 | + |
| 14 | +import { type FormType } from '../schema'; |
| 15 | + |
| 16 | +import i18n from './i18n.json'; |
| 17 | + |
| 18 | +interface Props { |
| 19 | + value: FormType; |
| 20 | + setFieldValue: (...entries: EntriesAsList<FormType>) => void; |
| 21 | + error: Error<FormType> | undefined; |
| 22 | + disabled?: boolean; |
| 23 | +} |
| 24 | + |
| 25 | +function EarlyAction(props: Props) { |
| 26 | + const { |
| 27 | + value, |
| 28 | + setFieldValue, |
| 29 | + error: formError, |
| 30 | + disabled, |
| 31 | + } = props; |
| 32 | + |
| 33 | + const strings = useTranslation(i18n); |
| 34 | + const error = getErrorObject(formError); |
| 35 | + |
2 | 36 | return ( |
3 | | - <> |
4 | | - This is Early Action Page. |
5 | | - </> |
| 37 | + <Container |
| 38 | + heading={strings.simplifiedEapActionHeading} |
| 39 | + > |
| 40 | + <InputSection |
| 41 | + title={strings.simplifiedEapIntervention} |
| 42 | + description={strings.simplifiedEapInterventionDescription} |
| 43 | + withAsteriskOnTitle |
| 44 | + > |
| 45 | + <TextArea |
| 46 | + label={strings.simplifiedEapActionDescription} |
| 47 | + name="interventation" |
| 48 | + value={value?.interventation} |
| 49 | + onChange={setFieldValue} |
| 50 | + error={undefined} |
| 51 | + disabled={disabled} |
| 52 | + /> |
| 53 | + </InputSection> |
| 54 | + {/* TODO: Add new component */} |
| 55 | + <InputSection |
| 56 | + title={strings.simplifiedEapActionPeopleTargeted} |
| 57 | + description={strings.simplifiedEapActionPeopleTargetedDescription} |
| 58 | + withAsteriskOnTitle |
| 59 | + numPreferredColumns={2} |
| 60 | + > |
| 61 | + <TextInput |
| 62 | + label={strings.simplifiedEapActionDescription} |
| 63 | + name="people_targeted" |
| 64 | + value={value?.people_targeted} |
| 65 | + onChange={setFieldValue} |
| 66 | + error={error?.people_targeted} |
| 67 | + disabled={disabled} |
| 68 | + /> |
| 69 | + </InputSection> |
| 70 | + <InputSection |
| 71 | + title={strings.simplifiedEapActionOperation} |
| 72 | + description={strings.simplifiedEapActionOperationDescription} |
| 73 | + withAsteriskOnTitle |
| 74 | + > |
| 75 | + <TextArea |
| 76 | + label={strings.simplifiedEapActionDescription} |
| 77 | + name="assisted_operation" |
| 78 | + value={value?.assisted_operation} |
| 79 | + onChange={setFieldValue} |
| 80 | + error={error?.assisted_operation} |
| 81 | + disabled={disabled} |
| 82 | + /> |
| 83 | + </InputSection> |
| 84 | + <InputSection |
| 85 | + description={strings.simplifiedEapActionCriteria} |
| 86 | + withAsteriskOnTitle |
| 87 | + > |
| 88 | + <TextArea |
| 89 | + label={strings.simplifiedEapActionDescription} |
| 90 | + name="targeted_criteria" |
| 91 | + value={value?.targeted_criteria} |
| 92 | + onChange={setFieldValue} |
| 93 | + error={error?.targeted_criteria} |
| 94 | + disabled={disabled} |
| 95 | + /> |
| 96 | + </InputSection> |
| 97 | + <InputSection |
| 98 | + title={strings.simplifiedEapActionsStatement} |
| 99 | + description={strings.simplifiedEapActionsStatementDescription} |
| 100 | + withAsteriskOnTitle |
| 101 | + > |
| 102 | + <TextArea |
| 103 | + label={strings.simplifiedEapActionDescription} |
| 104 | + name="trigger_statement" |
| 105 | + value={value?.trigger_statement} |
| 106 | + onChange={setFieldValue} |
| 107 | + error={error?.trigger_statement} |
| 108 | + disabled={disabled} |
| 109 | + /> |
| 110 | + </InputSection> |
| 111 | + <InputSection |
| 112 | + title={strings.simplifiedEapActionsLeadTime} |
| 113 | + description={strings.simplifiedEapActionsLeadTimeDescription} |
| 114 | + withAsteriskOnTitle |
| 115 | + numPreferredColumns={2} |
| 116 | + > |
| 117 | + <TextInput |
| 118 | + label={strings.simplifiedEapActionDescription} |
| 119 | + name="simplified_eap_lead_time" |
| 120 | + value={value?.simplified_eap_lead_time} |
| 121 | + onChange={setFieldValue} |
| 122 | + error={error?.simplified_eap_lead_time} |
| 123 | + disabled={disabled} |
| 124 | + /> |
| 125 | + </InputSection> |
| 126 | + <InputSection |
| 127 | + title={strings.simplifiedEapActionsOperational} |
| 128 | + description={strings.simplifiedEapActionsOperationalDescription} |
| 129 | + withAsteriskOnTitle |
| 130 | + numPreferredColumns={2} |
| 131 | + > |
| 132 | + <TextInput |
| 133 | + label={strings.simplifiedEapActionDescription} |
| 134 | + name="operation_timeframe" |
| 135 | + value={value?.operation_timeframe} |
| 136 | + onChange={setFieldValue} |
| 137 | + error={error?.operation_timeframe} |
| 138 | + disabled={disabled} |
| 139 | + /> |
| 140 | + </InputSection> |
| 141 | + <InputSection |
| 142 | + title={strings.simplifiedEapJustification} |
| 143 | + description={strings.simplifiedEapJustificationDescription} |
| 144 | + withAsteriskOnTitle |
| 145 | + > |
| 146 | + <TextArea |
| 147 | + label={strings.simplifiedEapActionDescription} |
| 148 | + name="trigger_threshold" |
| 149 | + value={value?.trigger_threshold} |
| 150 | + onChange={setFieldValue} |
| 151 | + error={error?.trigger_threshold} |
| 152 | + disabled={disabled} |
| 153 | + /> |
| 154 | + </InputSection> |
| 155 | + <InputSection |
| 156 | + title={strings.simplifiedEapFullEap} |
| 157 | + description={strings.simplifiedEapFullEapDescription} |
| 158 | + withAsteriskOnTitle |
| 159 | + > |
| 160 | + <TextArea |
| 161 | + label={strings.simplifiedEapActionDescription} |
| 162 | + name="full_eap" |
| 163 | + value={value?.full_eap} |
| 164 | + onChange={setFieldValue} |
| 165 | + error={error?.full_eap} |
| 166 | + disabled={disabled} |
| 167 | + /> |
| 168 | + </InputSection> |
| 169 | + </Container> |
6 | 170 | ); |
7 | 171 | } |
8 | 172 |
|
|
0 commit comments