Skip to content

Commit dc47211

Browse files
barshathakurishreeyash07
authored andcommitted
eap(lisitng): Add eap listing page
1 parent b974d32 commit dc47211

File tree

12 files changed

+224
-89
lines changed

12 files changed

+224
-89
lines changed

app/src/App/routes/index.tsx

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

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

12321215
const eapDevelopmentRegistrationForm = customWrapRoute({
12331216
parent: eapRegistrationLayout,
1234-
path: ':eapId/view',
1217+
path: ':eapId/',
12351218
component: {
12361219
render: () => import('#views/EapRegistration'),
12371220
props: {},
12381221
},
12391222
wrapperComponent: Auth,
12401223
context: {
1241-
title: 'View EAP Overview',
1224+
title: 'View EAP',
12421225
visibility: 'is-authenticated',
12431226
},
12441227
});
@@ -1503,7 +1486,7 @@ const wrappedRoutes = {
15031486
termsAndConditions,
15041487
operationalLearning,
15051488
montandonLandingPage,
1506-
eapDevelopmentRegistration,
1489+
newEapDevelopmentRegistration,
15071490
eapFullForm,
15081491
simplifiedEapForm,
15091492
...regionRoutes,
@@ -1521,7 +1504,6 @@ const wrappedRoutes = {
15211504
drefProcessLayout,
15221505
eapRegistrationLayout,
15231506
eapDevelopmentRegistrationForm,
1524-
eapRegistrationFormIndex,
15251507
};
15261508

15271509
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
@@ -195,3 +195,6 @@ export const multiMonthSelectDefaultValue = listToMap(
195195
export const ERU_READINESS_READY = 1;
196196
export const ERU_READINESS_CAN_CONTRIBUTE = 2;
197197
export const ERU_READINESS_NO_CAPACITY = 3;
198+
199+
export const EAP_TYPE_SIMPLIFIED = 20;
200+
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)