Skip to content

Commit 16caedf

Browse files
committed
Add new Signature component and neccessary constants
1 parent 3c10ea9 commit 16caedf

File tree

11 files changed

+131
-123
lines changed

11 files changed

+131
-123
lines changed

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

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import {
2828
} from '#utils/restRequest';
2929

3030
import i18n from './i18n.json';
31-
import styles from './styles.module.css';
3231

3332
type ExportTypeEnum = components<'read'>['schemas']['ExportTypeEnum'];
3433
type ExportStatusEnum = components<'read'>['schemas']['ExportStatusEnum'];
@@ -226,33 +225,31 @@ function DrefExportModal(props: Props) {
226225
|| exportStatusResponse?.status === EXPORT_STATUS_PENDING)
227226
&& drefType === DREF_TYPE_IMMINENT
228227
&& !drefImminentExportError && (
229-
<div className={styles.downloadButton}>
230-
{exportStatusResponse?.pdf_file ? (
231-
<Message
232-
title={strings.drefExportSuccessfully}
233-
description={strings.drefClickDownloadLink}
234-
actions={(
235-
<Link
236-
variant="secondary"
237-
href={exportStatusResponse?.pdf_file}
238-
external
239-
>
240-
{strings.drefDownloadPDF}
241-
</Link>
242-
)}
243-
/>
244-
) : (!exportStatusResponse && (
245-
<Button
246-
variant="secondary"
247-
name={undefined}
248-
onClick={handleDrefImminent}
249-
>
250-
{isPga
251-
? strings.drefDownloadPDFWithPGA
252-
: strings.drefDownloadPDFwithoutPGA}
253-
</Button>
254-
))}
255-
</div>
228+
exportStatusResponse?.pdf_file ? (
229+
<Message
230+
title={strings.drefExportSuccessfully}
231+
description={strings.drefClickDownloadLink}
232+
actions={(
233+
<Link
234+
variant="secondary"
235+
href={exportStatusResponse?.pdf_file}
236+
external
237+
>
238+
{strings.drefDownloadPDF}
239+
</Link>
240+
)}
241+
/>
242+
) : (!exportStatusResponse && (
243+
<Button
244+
variant="secondary"
245+
name={undefined}
246+
onClick={handleDrefImminent}
247+
>
248+
{isPga
249+
? strings.drefDownloadPDFWithPGA
250+
: strings.drefDownloadPDFwithoutPGA}
251+
</Button>
252+
))
256253
)}
257254
{isDefined(exportStatusResponse)
258255
&& exportStatusResponse.status === EXPORT_STATUS_COMPLETED

app/src/components/domain/DrefExportModal/styles.module.css

Lines changed: 0 additions & 6 deletions
This file was deleted.

app/src/views/DrefApplicationExport/PgaExport/index.tsx

Lines changed: 25 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Container,
44
DescriptionText,
55
Heading,
6+
Signature,
67
TextOutput,
78
type TextOutputProps,
89
} from '@ifrc-go/ui/printable';
@@ -30,10 +31,10 @@ function PgaExport() {
3031
<Heading level={2}>
3132
{strings.imminentDREFRequestHeading}
3233
</Heading>
33-
<Heading level={4}>
34-
{strings.requestHeading}
35-
</Heading>
36-
<Container>
34+
<Container
35+
heading={strings.requestHeading}
36+
headingLevel={4}
37+
>
3738
<DescriptionText>
3839
<ol
3940
className={styles.description}
@@ -45,10 +46,10 @@ function PgaExport() {
4546
</ol>
4647
</DescriptionText>
4748
</Container>
48-
<Heading level={4}>
49-
{strings.nationalSocietyHeading}
50-
</Heading>
51-
<Container>
49+
<Container
50+
heading={strings.nationalSocietyHeading}
51+
headingLevel={4}
52+
>
5253
<DescriptionText>
5354
<ol
5455
className={styles.description}
@@ -119,124 +120,82 @@ function PgaExport() {
119120
{strings.nationalSocietyDescriptionSixteen}
120121
</DescriptionText>
121122
</Container>
122-
<Heading level={4}>
123-
{strings.nationalSocietyBankDetails}
124-
</Heading>
125-
<Container>
123+
<Container
124+
heading={strings.nationalSocietyBankDetails}
125+
headingLevel={4}
126+
>
126127
<DescriptionText className={styles.tableDescription}>
127128
{strings.nationalSocietyBankDescription}
128129
</DescriptionText>
129130
<div className={styles.bankDetails}>
130131
<BlockTextOutput
131132
label={strings.nationalSocietyBankName}
132-
value=""
133-
invalidText
134133
/>
135134
<BlockTextOutput
136135
label={strings.nationalSocietyBankAccountNumber}
137-
value=""
138-
invalidText
139136
/>
140137
<BlockTextOutput
141138
label={strings.nationalSocietySwiftCode}
142-
value=""
143-
invalidText
144139
/>
145140
<BlockTextOutput
146141
label={strings.nationalSocietyAmount}
147142
value={strings.nationalSocietyAmountCHF}
148143
/>
149144
<BlockTextOutput
150145
label={strings.nationalSocietyAdvancePayment}
151-
value=""
152-
invalidText
153146
/>
154147
</div>
155148
<i>{strings.nationalSocietyBankFooter}</i>
156149
</Container>
157-
<Heading level={4}>
158-
{strings.imminentDrefRequest}
159-
</Heading>
160-
<Container>
150+
<Container
151+
heading={strings.imminentDrefRequest}
152+
headingLevel={4}
153+
>
161154
<div className={styles.drefSigned}>
162155
<TextOutput
163156
className={styles.drefTable}
164157
label={strings.imminentDrefSigned}
165-
value=""
166158
invalidText
167159
strongLabel
168160
withoutLabelColon
169161
/>
170162
<TextOutput
171163
className={styles.drefTable}
172164
label={strings.imminentIFRCSigned}
173-
value=""
174165
invalidText
175166
strongLabel
176167
withoutLabelColon
177168
/>
178-
<TextOutput
179-
className={styles.signature}
169+
<Signature
180170
label={strings.imminentSignature}
181-
value=""
182-
invalidText
183-
withoutLabelColon
184171
strongLabel
185172
/>
186-
<TextOutput
187-
className={styles.signature}
173+
<Signature
188174
label={strings.imminentSignature}
189-
value=""
190-
invalidText
191-
withoutLabelColon
192175
strongLabel
193176
/>
194-
<TextOutput
195-
className={styles.signature}
177+
<Signature
196178
label={strings.imminentPrintedSignatory}
197-
value=""
198-
invalidText
199-
withoutLabelColon
200179
strongLabel
201180
/>
202-
<TextOutput
203-
className={styles.signature}
181+
<Signature
204182
label={strings.imminentPrintedSignatory}
205-
value=""
206-
invalidText
207-
withoutLabelColon
208183
strongLabel
209184
/>
210-
<TextOutput
211-
className={styles.signature}
185+
<Signature
212186
label={strings.imminentTitle}
213-
value=""
214-
invalidText
215-
withoutLabelColon
216187
strongLabel
217188
/>
218-
<TextOutput
219-
className={styles.signature}
189+
<Signature
220190
label={strings.imminentTitle}
221-
value=""
222-
invalidText
223-
withoutLabelColon
224191
strongLabel
225192
/>
226-
<TextOutput
227-
className={styles.signature}
193+
<Signature
228194
label={strings.imminentDate}
229-
value=""
230-
invalidText
231-
withoutLabelColon
232195
strongLabel
233196
/>
234-
<TextOutput
235-
className={styles.signature}
197+
<Signature
236198
label={strings.imminentDate}
237-
value=""
238-
invalidText
239-
withoutLabelColon
240199
strongLabel
241200
/>
242201
</div>

app/src/views/DrefApplicationExport/PgaExport/styles.module.css

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,5 @@
2929
align-items: center;
3030
flex-direction: column;
3131
}
32-
33-
.signature {
34-
display: flex;
35-
align-items: center;
36-
flex-direction: column;
37-
border-top: var(--go-ui-width-separator-md) solid var(--go-ui-color-separator);
38-
}
3932
}
40-
}
33+
}

app/src/views/DrefApplicationExport/index.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,10 +1051,11 @@ export function Component() {
10511051
)}
10521052
{proposedActionsDefined && (
10531053
<>
1054-
<Heading level={3}>
1055-
{strings.proposedActions}
1056-
</Heading>
1057-
<Container childrenContainerClassName={styles.actionsSection}>
1054+
<Container
1055+
heading={strings.proposedActions}
1056+
headingLevel={3}
1057+
childrenContainerClassName={styles.actionsSection}
1058+
>
10581059
<div className={styles.actionsItem} />
10591060
<DescriptionText
10601061
className={styles.actionsTitle}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ function Operation(props: Props) {
108108
setValue,
109109
} = props;
110110

111-
const onProposedActionChange = useCallback(
111+
const handleProposedActionChange = useCallback(
112112
(val: SetValueArg<ProposedActionsFormFields>, index: number | undefined) => {
113113
setValue((oldVal) => {
114114
const newProposedValue = [...(oldVal.proposed_action ?? [])];
@@ -136,7 +136,7 @@ function Operation(props: Props) {
136136
[setValue],
137137
);
138138

139-
const onProposedActionRemove = useCallback(
139+
const handleProposedActionRemove = useCallback(
140140
(index: number) => {
141141
setValue(
142142
(oldValue) => {
@@ -911,8 +911,8 @@ function Operation(props: Props) {
911911
index={action.mainIndex}
912912
value={action}
913913
activityOptions={activityOptionResponse}
914-
onChange={onProposedActionChange}
915-
onRemove={onProposedActionRemove}
914+
onChange={handleProposedActionChange}
915+
onRemove={handleProposedActionRemove}
916916
error={getErrorObject(error?.proposed_action)}
917917
/>
918918
))}
@@ -952,8 +952,8 @@ function Operation(props: Props) {
952952
index={action.mainIndex}
953953
value={action}
954954
activityOptions={activityOptionResponse}
955-
onChange={onProposedActionChange}
956-
onRemove={onProposedActionRemove}
955+
onChange={handleProposedActionChange}
956+
onRemove={handleProposedActionRemove}
957957
error={getErrorObject(error?.proposed_action)}
958958
/>
959959
))}

app/src/views/DrefApplicationForm/common.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ export const DISASTER_FIRE = 15;
2929
export const DISASTER_FLASH_FLOOD = 27;
3030
export const DISASTER_FLOOD = 12;
3131

32+
export const SURGE_DEPLOYMENT_COST = 10000;
33+
export const SURGE_INDIRECT_COST = 5800;
34+
export const INDIRECT_COST = 5000;
35+
export const SUB_TOTAL = 75000;
36+
3237
export const EARLY_ACTIONS = 1 satisfies ProposedActionOption['key'];
3338
export const EARLY_RESPONSE = 2 satisfies ProposedActionOption['key'];
3439

@@ -175,8 +180,8 @@ export const recalculateProposedActionValues = (val: PartialDref) => {
175180
// if Surge Personnel are not deployed,
176181
// the Surge Deployment cost will not be applicable,
177182
// and the Indirect Costs will be CHF 5,000
178-
const surgeDeploymentCost = val.is_surge_personnel_deployed ? 10000 : undefined;
179-
const indirectCost = val.is_surge_personnel_deployed ? 5800 : 5000;
183+
const surgeDeploymentCost = val.is_surge_personnel_deployed ? SURGE_DEPLOYMENT_COST : undefined;
184+
const indirectCost = val.is_surge_personnel_deployed ? SURGE_INDIRECT_COST : INDIRECT_COST;
180185

181186
const total = sumSafe(
182187
[subTotal, indirectCost, surgeDeploymentCost],

app/src/views/DrefApplicationForm/schema.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ import {
2727
DISASTER_FIRE,
2828
DISASTER_FLASH_FLOOD,
2929
DISASTER_FLOOD,
30+
INDIRECT_COST,
31+
SUB_TOTAL,
32+
SURGE_INDIRECT_COST,
3033
TYPE_ASSESSMENT,
3134
TYPE_IMMINENT,
3235
TYPE_LOAN,
@@ -783,7 +786,7 @@ const schema: DrefFormSchema = {
783786
validations: [
784787
(value: Maybe<number>) => (
785788
// FIXME: use translations
786-
isDefined(value) && value !== 75000
789+
isDefined(value) && value !== SUB_TOTAL
787790
? 'The sub-total of the budgets should be exactly CHF 75000'
788791
: undefined
789792
),
@@ -813,7 +816,7 @@ const schema: DrefFormSchema = {
813816
required: true,
814817
validations: [
815818
positiveIntegerCondition,
816-
lessThanOrEqualToCondition(5800),
819+
lessThanOrEqualToCondition(SURGE_INDIRECT_COST),
817820
],
818821
},
819822
};
@@ -824,7 +827,7 @@ const schema: DrefFormSchema = {
824827
required: true,
825828
validations: [
826829
positiveIntegerCondition,
827-
lessThanOrEqualToCondition(5000),
830+
lessThanOrEqualToCondition(INDIRECT_COST),
828831
],
829832
},
830833
};

0 commit comments

Comments
 (0)