Skip to content

Commit 671b35f

Browse files
shreeyash07frozenhelium
authored andcommitted
fix(dref-translation): update finalize access and add info section of status in dref table
1 parent e9a2c7e commit 671b35f

File tree

4 files changed

+81
-3
lines changed

4 files changed

+81
-3
lines changed

app/src/utils/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ export const DREF_STATUS_DRAFT = 1 satisfies DrefStatus;
8888
export const DREF_STATUS_FINALIZING = 2 satisfies DrefStatus;
8989
export const DREF_STATUS_FINALIZED = 3 satisfies DrefStatus;
9090
export const DREF_STATUS_APPROVED = 4 satisfies DrefStatus;
91+
export const DREF_STATUS_FAILED = 5 satisfies DrefStatus;
9192

9293
export type TypeOfDrefEnum = components<'read'>['schemas']['DrefDrefDrefTypeEnumKey'];
9394
export const DREF_TYPE_IMMINENT = 0 satisfies TypeOfDrefEnum;

app/src/views/AccountMyFormsDref/ActiveDrefTable/i18n.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
"activeDrefTableStageHeading": "Stage",
99
"activeDrefTableTypeOfDrefHeading": "Type of DREF",
1010
"activeDrefTableCountryHeading": "Country",
11-
"activeDrefTableStatusHeading": "Status"
11+
"activeDrefTableStatusHeading": "Status",
12+
"activeDrefTableStatusDraftDescription": "The form is in its initial stage and has not been finalized yet.",
13+
"activeDrefTableStatusFinalizingDescription": "The form is being finalizing. The original language content is being translated into English.",
14+
"activeDrefTableStatusFinalizedDescription": "The form has been finalized, and the original language has been switched to English. All further edits must now be made in English.",
15+
"activeDrefTableStatusApprovedDescription": "Approved: The form has been reviewed and approved.",
16+
"activeDrefTableStatusFailedDescription": "The form finalization process has failed. You can retry to finalize the form again"
1217
}
1318
}

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

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
Pager,
99
Table,
1010
TableBodyContent,
11+
TextOutput,
1112
} from '@ifrc-go/ui';
1213
import { type RowOptions } from '@ifrc-go/ui';
1314
import { type Language } from '@ifrc-go/ui/contexts';
@@ -28,10 +29,14 @@ import {
2829
listToMap,
2930
} from '@togglecorp/fujs';
3031

32+
import useGlobalEnums from '#hooks/domain/useGlobalEnums';
3133
import useUserMe from '#hooks/domain/useUserMe';
3234
import useFilterState from '#hooks/useFilterState';
3335
import {
3436
DREF_STATUS_APPROVED,
37+
DREF_STATUS_DRAFT,
38+
DREF_STATUS_FAILED,
39+
DREF_STATUS_FINALIZED,
3540
DREF_STATUS_FINALIZING,
3641
DREF_TYPE_LOAN,
3742
type TypeOfDrefEnum,
@@ -72,6 +77,8 @@ function ActiveDrefTable(props: Props) {
7277
pageSize: 6,
7378
});
7479

80+
const { dref_dref_status: drefStatus } = useGlobalEnums();
81+
7582
const {
7683
response: activeDrefResponse,
7784
pending: activeDrefResponsePending,
@@ -179,6 +186,53 @@ function ActiveDrefTable(props: Props) {
179186
[],
180187
);
181188

189+
const statusDescription = useMemo(() => {
190+
if (isNotDefined(drefStatus)) {
191+
return undefined;
192+
}
193+
194+
const statusMap = listToMap(
195+
drefStatus,
196+
(item) => item.key,
197+
(item) => item.value,
198+
);
199+
200+
return [
201+
{
202+
key: DREF_STATUS_DRAFT,
203+
status: statusMap[DREF_STATUS_DRAFT],
204+
description: strings.activeDrefTableStatusDraftDescription,
205+
},
206+
{
207+
key: DREF_STATUS_FINALIZING,
208+
status: statusMap[DREF_STATUS_FINALIZING],
209+
description: strings.activeDrefTableStatusFinalizingDescription,
210+
},
211+
{
212+
key: DREF_STATUS_FINALIZED,
213+
status: statusMap[DREF_STATUS_FINALIZED],
214+
description: strings.activeDrefTableStatusFinalizedDescription,
215+
},
216+
{
217+
key: DREF_STATUS_APPROVED,
218+
status: statusMap[DREF_STATUS_APPROVED],
219+
description: strings.activeDrefTableStatusApprovedDescription,
220+
},
221+
{
222+
key: DREF_STATUS_FAILED,
223+
status: statusMap[DREF_STATUS_FAILED],
224+
description: strings.activeDrefTableStatusFailedDescription,
225+
},
226+
];
227+
}, [
228+
drefStatus,
229+
strings.activeDrefTableStatusDraftDescription,
230+
strings.activeDrefTableStatusFinalizingDescription,
231+
strings.activeDrefTableStatusFinalizedDescription,
232+
strings.activeDrefTableStatusApprovedDescription,
233+
strings.activeDrefTableStatusFailedDescription,
234+
]);
235+
182236
const baseColumns = useMemo(
183237
() => ([
184238
createDateColumn<LatestDref, Key>(
@@ -221,7 +275,21 @@ function ActiveDrefTable(props: Props) {
221275
'status',
222276
strings.activeDrefTableStatusHeading,
223277
(item) => item.status_display,
224-
{ columnClassName: styles.status },
278+
{
279+
columnClassName: styles.status,
280+
headerInfoTitle: strings.activeDrefTableStatusHeading,
281+
headerInfoDescription: (
282+
statusDescription?.map((status) => (
283+
<TextOutput
284+
key={status.key}
285+
strongLabel
286+
withoutLabelColon
287+
label={status.status}
288+
value={status.description}
289+
/>
290+
))
291+
),
292+
},
225293
),
226294
createElementColumn<LatestDref, Key, DrefTableActionsProps>(
227295
'actions',
@@ -306,6 +374,7 @@ function ActiveDrefTable(props: Props) {
306374
userMe,
307375
userRegionCoordinatorMap,
308376
refetchActiveDref,
377+
statusDescription,
309378
],
310379
);
311380

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import useRouting from '#hooks/useRouting';
4343
import { languageNameMap } from '#utils/common';
4444
import {
4545
DREF_STATUS_DRAFT,
46+
DREF_STATUS_FAILED,
4647
DREF_STATUS_FINALIZED,
4748
DREF_TYPE_IMMINENT,
4849
DREF_TYPE_LOAN,
@@ -563,7 +564,9 @@ function DrefTableActions(props: Props) {
563564

564565
const canApprove = status === DREF_STATUS_FINALIZED && hasPermissionToApprove;
565566

566-
const canFinalize = status === DREF_STATUS_DRAFT && hasPermissionToApprove;
567+
const canFinalize = status === (DREF_STATUS_DRAFT
568+
|| DREF_STATUS_FAILED)
569+
&& hasPermissionToApprove;
567570

568571
const shouldConfirmImminentAddOpsUpdate = drefType === DREF_TYPE_IMMINENT && isDrefImminentV2;
569572

0 commit comments

Comments
 (0)