-
Notifications
You must be signed in to change notification settings - Fork 125
/
DashboardUnreadMessages.jsx
72 lines (65 loc) · 1.88 KB
/
DashboardUnreadMessages.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import React, { useMemo } from 'react';
import { useSelector } from 'react-redux';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { Paths, ErrorMessages } from '../../util/constants';
import HorizontalRule from '../shared/HorizontalRule';
const DashboardUnreadMessages = props => {
const { inbox } = props;
const { noAssociations, allTriageGroupsBlocked } = useSelector(
state => state.sm.recipients,
);
const unreadCountHeader = useMemo(
() => {
return (
inbox !== undefined && (
<h2
data-dd-privacy="mask"
data-testid="unread-messages"
className="vads-u-font-size--h3"
slot="headline"
>
{inbox === null
? ErrorMessages.LandingPage.GET_INBOX_ERROR
: `${inbox.unreadCount} unread message${
inbox.unreadCount === 0 || inbox.unreadCount > 1 ? 's' : ''
} in your inbox`}
</h2>
)
);
},
[inbox],
);
return (
<va-alert status="info" visible uswds>
{unreadCountHeader}
<div className="vads-u-margin-top--1p5">
<Link
className="vads-c-action-link--blue vads-u-margin-top--1"
data-testid="inbox-link"
text="Go to your inbox"
to={Paths.INBOX}
>
Go to your inbox
</Link>
{!noAssociations &&
!allTriageGroupsBlocked && (
<>
<HorizontalRule />
<Link
data-testid="compose-message-link"
className="vads-c-action-link--blue"
to={Paths.COMPOSE}
>
Start a new message
</Link>
</>
)}
</div>
</va-alert>
);
};
DashboardUnreadMessages.propTypes = {
inbox: PropTypes.object,
};
export default DashboardUnreadMessages;