-
Notifications
You must be signed in to change notification settings - Fork 125
/
EnrollmentVerificationBreadcrumbs.jsx
56 lines (51 loc) · 1.35 KB
/
EnrollmentVerificationBreadcrumbs.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
54
55
56
import React from 'react';
import {
BASE_URL,
REVIEW_ENROLLMENTS_URL,
REVIEW_ENROLLMENTS_URL_SEGMENT,
VERIFY_ENROLLMENTS_ERROR_URL_SEGMENT,
VERIFY_ENROLLMENTS_RELATIVE_URL,
VERIFY_ENROLLMENTS_URL_SEGMENT,
} from '../constants';
export default function EnrollmentVerificationBreadcrumbs() {
const breadcrumbs = [
<a href="/" key="home">
Home
</a>,
<a href="/education/" key="education-and-training">
Education and training
</a>,
<a href={BASE_URL} key="enrollment-history">
Verify your school enrollments for GI Bill benefits
</a>,
];
// Get the last non-empty segment of the URL.
const page = window.location.href
.split('/')
.reverse()
.find(s => !!s.trim() && !s.startsWith('?'));
if (
[REVIEW_ENROLLMENTS_URL_SEGMENT, VERIFY_ENROLLMENTS_URL_SEGMENT].includes(
page,
)
) {
breadcrumbs.push(
<a href={REVIEW_ENROLLMENTS_URL} key="review-enrollments">
Post-9/11 GI Bill enrollment verifications
</a>,
);
}
if (
[
VERIFY_ENROLLMENTS_URL_SEGMENT,
VERIFY_ENROLLMENTS_ERROR_URL_SEGMENT,
].includes(page)
) {
breadcrumbs.push(
<a href={VERIFY_ENROLLMENTS_RELATIVE_URL} key="verify-enrollments">
Verify your enrollments
</a>,
);
}
return <va-breadcrumbs uswds="false">{breadcrumbs}</va-breadcrumbs>;
}