Skip to content

Commit ea21794

Browse files
barshathakurishreeyash07
authored andcommitted
eap(lisitng): Add eap listing page
1 parent 4bc7988 commit ea21794

11 files changed

Lines changed: 223 additions & 88 deletions

File tree

app/src/App/routes/index.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,24 +1198,7 @@ const eapRegistrationLayout = customWrapRoute({
11981198
},
11991199
});
12001200

1201-
const eapRegistrationFormIndex = customWrapRoute({
1202-
parent: eapRegistrationLayout,
1203-
index: true,
1204-
component: {
1205-
eagerLoad: true,
1206-
render: Navigate,
1207-
props: {
1208-
to: 'new' satisfies DefaultPerProcessChild,
1209-
replace: true,
1210-
},
1211-
},
1212-
context: {
1213-
title: 'EAP Registration',
1214-
visibility: 'anything',
1215-
},
1216-
});
1217-
1218-
const eapDevelopmentRegistration = customWrapRoute({
1201+
const newEapDevelopmentRegistration = customWrapRoute({
12191202
parent: eapRegistrationLayout,
12201203
path: 'new' satisfies DefaultEapRegistrationChild,
12211204
component: {
@@ -1232,14 +1215,14 @@ const eapDevelopmentRegistration = customWrapRoute({
12321215

12331216
const eapDevelopmentRegistrationForm = customWrapRoute({
12341217
parent: eapRegistrationLayout,
1235-
path: ':eapId/view',
1218+
path: ':eapId/',
12361219
component: {
12371220
render: () => import('#views/EapRegistration'),
12381221
props: {},
12391222
},
12401223
wrapperComponent: Auth,
12411224
context: {
1242-
title: 'View EAP Overview',
1225+
title: 'View EAP',
12431226
visibility: 'is-authenticated',
12441227
},
12451228
});
@@ -1504,7 +1487,7 @@ const wrappedRoutes = {
15041487
termsAndConditions,
15051488
operationalLearning,
15061489
montandonLandingPage,
1507-
eapDevelopmentRegistration,
1490+
newEapDevelopmentRegistration,
15081491
eapFullForm,
15091492
simplifiedEapForm,
15101493
...regionRoutes,
@@ -1522,7 +1505,6 @@ const wrappedRoutes = {
15221505
drefProcessLayout,
15231506
eapRegistrationLayout,
15241507
eapDevelopmentRegistrationForm,
1525-
eapRegistrationFormIndex,
15261508
};
15271509

15281510
export const unwrappedRoutes = unwrapRoute(Object.values(wrappedRoutes));

app/src/utils/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,6 @@ export const multiMonthSelectDefaultValue = listToMap(
199199
export const ERU_READINESS_READY = 1;
200200
export const ERU_READINESS_CAN_CONTRIBUTE = 2;
201201
export const ERU_READINESS_NO_CAPACITY = 3;
202+
203+
export const EAP_TYPE_SIMPLIFIED = 20;
204+
export const EAP_TYPE_FULL = 10;

app/src/views/EapApplications/EapTableActions/i18n.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"namespace":"accountMyFormsEap",
33
"strings":{
44
"eapViewLabel": "View",
5+
"eapEditLabel": "Edit",
56
"eapFormLink": "Start Full EAP",
67
"simplifiedEapLink": "Start sEAP"
78
}

app/src/views/EapApplications/EapTableActions/index.tsx

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,24 @@ function EapTableActions(props: Props) {
1818
return (
1919
<TableActions
2020
extraActions={(
21-
<DropdownMenuItem
22-
type="link"
23-
to="eapDevelopmentRegistrationForm"
24-
urlParams={{ eapId }}
25-
>
26-
{strings.eapViewLabel}
27-
</DropdownMenuItem>
21+
<>
22+
<DropdownMenuItem
23+
type="link"
24+
to="eapDevelopmentRegistrationForm"
25+
urlParams={{ eapId }}
26+
state={{ mode: 'view' }}
27+
>
28+
{strings.eapViewLabel}
29+
</DropdownMenuItem>
30+
<DropdownMenuItem
31+
type="link"
32+
to="eapDevelopmentRegistrationForm"
33+
urlParams={{ eapId }}
34+
state={{ mode: 'edit' }}
35+
>
36+
{strings.eapEditLabel}
37+
</DropdownMenuItem>
38+
</>
2839
)}
2940
>
3041
<Link

app/src/views/EapApplications/i18n.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
"namespace": "eapApplication",
33
"strings": {
44
"eapRegistrationLink": "Register Your EAP",
5-
"eapApplicationsHeading": "EAP Application"
5+
"eapApplicationsHeading": "EAP Application",
6+
"eapLastUpdated": "Last Updated",
7+
"eapName": "Name/Phase",
8+
"eapType": "EAP Type",
9+
"eapStatus": "Status",
10+
"eapRegistration": "EAP Registration"
611
}
712
}

app/src/views/EapApplications/index.tsx

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
} from 'react';
66
import {
77
Container,
8+
Pager,
89
type RowOptions,
910
Table,
1011
TableBodyContent,
@@ -22,6 +23,10 @@ import {
2223

2324
import Link from '#components/Link';
2425
import useFilterState from '#hooks/useFilterState';
26+
import {
27+
EAP_TYPE_FULL,
28+
EAP_TYPE_SIMPLIFIED,
29+
} from '#utils/constants';
2530
import {
2631
type GoApiResponse,
2732
useRequest,
@@ -37,6 +42,7 @@ type EapResponse = GoApiResponse<'/api/v2/eap-registration/'>;
3742
type EapListItem = NonNullable<EapResponse['results']>[number];
3843

3944
type Key = EapListItem['id'];
45+
const ITEM_PER_PAGE = 6;
4046

4147
/** @knipignore */
4248
// eslint-disable-next-line import/prefer-default-export
@@ -50,9 +56,11 @@ export function Component() {
5056
rawFilter,
5157
filtered,
5258
setFilterField,
59+
page,
60+
setPage,
5361
} = useFilterState<FilterValue>({
5462
filter: {},
55-
pageSize: 6,
63+
pageSize: ITEM_PER_PAGE,
5664
});
5765

5866
const {
@@ -82,19 +90,18 @@ export function Component() {
8290
() => ([
8391
createDateColumn<EapListItem, number>(
8492
'created_at',
85-
'Last Updated',
93+
strings.eapLastUpdated,
8694
(item) => item.created_at,
87-
{ columnClassName: styles.date },
8895
),
8996
createStringColumn<EapListItem, number>(
9097
'name',
91-
'Name/Phase',
98+
strings.eapName,
9299
(item) => {
93100
const baseYear = new Date(item.created_at).getFullYear();
94101
let addedYear = baseYear;
95-
if (item.eap_type === 10) {
96-
addedYear = baseYear + 4;
97-
} else if (item.eap_type === 20) {
102+
if (item.eap_type === EAP_TYPE_FULL) {
103+
addedYear = baseYear + 5;
104+
} else if (item.eap_type === EAP_TYPE_SIMPLIFIED) {
98105
addedYear = baseYear + 2;
99106
}
100107
return `${item.country_details?.name}:
@@ -105,24 +112,15 @@ export function Component() {
105112
),
106113
createStringColumn<EapListItem, number>(
107114
'eap_type_display',
108-
'EAP Type',
115+
strings.eapType,
109116
(item) => item.eap_type_display,
110-
{ columnClassName: styles.type },
111117
),
112118
createStringColumn<EapListItem, number>(
113119
'status_display',
114-
'Status',
120+
strings.eapStatus,
115121
(item) => item.status_display,
116122
{ columnClassName: styles.status },
117123
),
118-
]),
119-
[],
120-
);
121-
122-
const aggregatedColumns = useMemo(
123-
() => ([
124-
createExpansionIndicatorColumn<EapListItem, Key>(false),
125-
...baseColumns,
126124
createExpandColumn<EapListItem, Key>(
127125
'expandRow',
128126
'',
@@ -132,7 +130,14 @@ export function Component() {
132130
}),
133131
),
134132
]),
135-
[baseColumns, handleExpandClick, expandedRow],
133+
[
134+
strings.eapLastUpdated,
135+
strings.eapName,
136+
strings.eapType,
137+
strings.eapStatus,
138+
expandedRow,
139+
handleExpandClick,
140+
],
136141
);
137142

138143
const detailColumns = useMemo(
@@ -141,22 +146,21 @@ export function Component() {
141146
createStringColumn<EapListItem, number>(
142147
'title',
143148
'',
144-
() => 'EAP Registration',
149+
() => strings.eapRegistration,
145150
{ columnClassName: styles.detailTitle },
146151
),
152+
createEmptyColumn(),
147153
createElementColumn<EapListItem, number, EapTableActionProps>(
148154
'actions',
149-
'EAP Registration',
155+
'',
150156
EapTableActions,
151157
(eapId) => ({
152158
eapId,
153159
}),
154160
),
155161
createEmptyColumn(),
156-
createEmptyColumn(),
157-
createEmptyColumn(),
158162
]),
159-
[],
163+
[strings.eapRegistration],
160164
);
161165

162166
const rowModifier = useCallback(
@@ -193,25 +197,33 @@ export function Component() {
193197
childrenContainerClassName={styles.eapFormLinks}
194198
heading={strings.eapApplicationsHeading}
195199
withHeaderBorder
196-
filters={(
200+
filters={(eapResponse?.count ?? 0) > 0 && (
197201
<Filters
198202
value={rawFilter}
199203
onChange={setFilterField}
200204
/>
201205
)}
202206
actions={(
203207
<Link
204-
to="home"
208+
to="newEapDevelopmentRegistration"
205209
variant="secondary"
206210
>
207211
{strings.eapRegistrationLink}
208212
</Link>
209213
)}
214+
footerActions={(
215+
<Pager
216+
activePage={page}
217+
itemsCount={eapResponse?.count ?? 0}
218+
maxItemsPerPage={limit}
219+
onActivePageChange={setPage}
220+
/>
221+
)}
210222
>
211223
<Table
212224
className={styles.table}
213225
data={eapResponse?.results}
214-
columns={aggregatedColumns}
226+
columns={baseColumns}
215227
rowModifier={rowModifier}
216228
keySelector={numericIdSelector}
217229
pending={eapPending}

app/src/views/EapApplications/styles.module.css

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
.eap-form-links {
22
.table {
3-
.type,
4-
.status,
5-
.date {
3+
.status {
64
width: 0%;
7-
min-width: 7rem;
5+
min-width: 19rem;
86
}
9-
107
.sub-cell {
118
border-bottom: unset;
129
background-color: var(--go-ui-color-gray-20);

app/src/views/EapRegistration/i18n.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,15 @@
3737
"eapFocalPointEmail": "Email",
3838
"eapFocalPointPhoneNumber": "Phone Number",
3939
"eapSubmitButton": "Submit",
40+
"eapBackButton": "Back",
4041
"eapCancelButton": "Cancel",
4142
"eapRegistrationFailure": "Sorry could not register new EAP right now!",
4243
"eapRegistrationSuccess": "Successfully created a new EAP!",
4344
"eapNotSure": "Not Sure",
4445
"eapDevelopmentRegistrationHeading": "EAP Development Registration",
45-
"eapDevelopmentRegistrationDescription": "Thank you for notifying us about the start of your EAP process. We look forward to your completed application."
46+
"eapDevelopmentRegistrationDescription": "Thank you for notifying us about the start of your EAP process. We look forward to your completed application.",
47+
"eapFailedToLoad": "Failed to Load",
48+
"eapRegistrationUpdateMessage": "EAP Registration updated Successfully.",
49+
"eapRegistrationFailureMessage": "Failed to update EAP Registration"
4650
}
4751
}

0 commit comments

Comments
 (0)