-
Notifications
You must be signed in to change notification settings - Fork 125
/
GiBillBreadcrumbs.jsx
53 lines (46 loc) · 1.24 KB
/
GiBillBreadcrumbs.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React from 'react';
import { VaBreadcrumbs } from '@department-of-veterans-affairs/web-components/react-bindings';
import { useRouteMatch, Link } from 'react-router-dom';
import { giDocumentTitle, useQueryParams } from '../utils/helpers';
const GiBillBreadcrumbs = () => {
const profileMatch = useRouteMatch('/institution/:facilityCode');
const compareMatch = useRouteMatch('/compare');
const queryParams = useQueryParams();
const version = queryParams.get('version');
const crumbLiEnding = giDocumentTitle();
const root = version
? {
pathname: '/',
}
: '/';
const crumbs = [
<a href="/" key="home">
Home
</a>,
<a href="/education/" key="education">
Education and training
</a>,
<Link to={root} key="main">
{crumbLiEnding}
</Link>,
];
if (profileMatch) {
crumbs.push(
<Link
to={`/institution/${profileMatch.params.facilityCode}`}
key="result-detail"
>
Institution details
</Link>,
);
}
if (compareMatch) {
crumbs.push(
<Link to={root} key="main">
Institution comparison
</Link>,
);
}
return <VaBreadcrumbs uswds="false">{crumbs}</VaBreadcrumbs>;
};
export default GiBillBreadcrumbs;