Skip to content

Commit 6b66c26

Browse files
committed
fix(eap-export): update parent export file for eap
1 parent 1bf5fe3 commit 6b66c26

File tree

6 files changed

+45
-43
lines changed

6 files changed

+45
-43
lines changed

app/src/App/routes/index.tsx

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,30 +1226,16 @@ const eapDevelopmentRegistrationForm = customWrapRoute({
12261226
},
12271227
});
12281228

1229-
const eapFullExport = customWrapRoute({
1230-
parent: rootLayout,
1231-
path: 'eap/:eapId/full/export',
1232-
component: {
1233-
render: () => import('#views/EapFullExport'),
1234-
props: {},
1235-
},
1236-
wrapperComponent: Auth,
1237-
context: {
1238-
title: 'Full EAP Export',
1239-
visibility: 'is-authenticated',
1240-
},
1241-
});
1242-
1243-
const simplifiedEapExport = customWrapRoute({
1229+
const eapExport = customWrapRoute({
12441230
parent: rootLayout,
12451231
path: 'eap/:eapId/export',
12461232
component: {
1247-
render: () => import('#views/SimplifiedEapExport'),
1233+
render: () => import('#views/EapExport'),
12481234
props: {},
12491235
},
12501236
wrapperComponent: Auth,
12511237
context: {
1252-
title: 'Simplified EAP Export',
1238+
title: 'EAP Export',
12531239
visibility: 'is-authenticated',
12541240
},
12551241
});
@@ -1532,8 +1518,7 @@ const wrappedRoutes = {
15321518
drefProcessLayout,
15331519
eapRegistrationLayout,
15341520
eapDevelopmentRegistrationForm,
1535-
simplifiedEapExport,
1536-
eapFullExport,
1521+
eapExport,
15371522
};
15381523

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

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

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,9 @@ function EapTableActions(props: Props) {
6060
return (
6161
<>
6262
<ListView layout="block">
63-
{type === 'development' && eap.eap_type === EAP_TYPE_SIMPLIFIED && (
64-
<Link
65-
to="simplifiedEapExport"
66-
urlParams={{ eapId: eap.id }}
67-
urlSearch={isDefined(details?.data.version)
68-
? `version=${details.data.version}`
69-
: undefined}
70-
title="Preview export"
71-
before={<DocumentPdfLineIcon fontSize={18} />}
72-
>
73-
Preview export
74-
</Link>
75-
)}
76-
{type === 'development' && eap.eap_type === EAP_TYPE_FULL && (
63+
{type === 'development' && (
7764
<Link
78-
to="eapFullExport"
65+
to="eapExport"
7966
urlParams={{ eapId: eap.id }}
8067
urlSearch={isDefined(details?.data.version)
8168
? `version=${details.data.version}`

app/src/views/EapExport/index.tsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useParams } from 'react-router-dom';
2+
import {
3+
isFalsyString,
4+
isTruthyString,
5+
} from '@togglecorp/fujs';
6+
7+
import { EAP_TYPE_FULL } from '#utils/constants';
8+
import { useRequest } from '#utils/restRequest';
9+
import EapFullExport from '#views/EapFullExport';
10+
import SimplifiedEapExport from '#views/SimplifiedEapExport';
11+
12+
/** @knipignore */
13+
// eslint-disable-next-line import/prefer-default-export
14+
export function Component() {
15+
const { eapId } = useParams<{ eapId: string }>();
16+
17+
const { response: eapRegistrationResponse } = useRequest({
18+
skip: isFalsyString(eapId),
19+
url: '/api/v2/eap-registration/{id}/',
20+
pathVariables: isTruthyString(eapId)
21+
? {
22+
id: Number(eapId),
23+
}
24+
: undefined,
25+
});
26+
27+
const eapType = eapRegistrationResponse?.eap_type;
28+
29+
return eapType === EAP_TYPE_FULL ? (
30+
<EapFullExport />
31+
) : (
32+
<SimplifiedEapExport />
33+
);
34+
}
35+
36+
Component.displayName = 'EapExport';

app/src/views/EapFullExport/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ type Sector = NonNullable<
3838
>['sector'];
3939

4040
/** @knipignore */
41-
// eslint-disable-next-line import/prefer-default-export
42-
export function Component() {
41+
export default function EapFullExport() {
4342
const { eapId } = useParams<{ eapId: string }>();
4443

4544
const [searchParams] = useSearchParams();
@@ -1762,5 +1761,3 @@ export function Component() {
17621761
</PrintablePage>
17631762
);
17641763
}
1765-
1766-
Component.displayName = 'EapFullExport';

app/src/views/SimplifiedEapExport/index.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ import i18n from './i18n.json';
2424
import styles from './styles.module.css';
2525

2626
/** @knipignore */
27-
// eslint-disable-next-line import/prefer-default-export
28-
export function Component() {
27+
export default function SimplifiedEapExport() {
2928
const { eapId } = useParams<{ eapId: string }>();
3029
const [searchParams] = useSearchParams();
3130

@@ -601,5 +600,3 @@ export function Component() {
601600
</PrintablePage>
602601
);
603602
}
604-
605-
Component.displayName = 'SimplifiedEapExport';

go-api

Submodule go-api updated 55 files

0 commit comments

Comments
 (0)