-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathNotification.js
More file actions
41 lines (35 loc) · 1.08 KB
/
Notification.js
File metadata and controls
41 lines (35 loc) · 1.08 KB
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
import React, { useCallback, useMemo } from 'react'
import { Tabs, Tab } from 'react-bootstrap'
import { useHistory, useLocation } from 'react-router-dom'
import { Notifications } from './Notifications'
import Subscriptions from './Subscriptions'
import _ from 'lodash'
const NOTIFICATIONS_PATHNAME_MAP = {
Messages: '/notifications',
Subscriptions: '/notifications/subscriptions',
}
export default function Notification() {
const history = useHistory()
const { pathname } = useLocation()
const handleSelect = useCallback(
(key) => {
history.push(NOTIFICATIONS_PATHNAME_MAP[key])
},
[history]
)
const activeKey = useMemo(() => {
return _.invert(NOTIFICATIONS_PATHNAME_MAP)[pathname]
}, [pathname])
return (
<Tabs mountOnEnter id="tabs-notifications" activeKey={activeKey} onSelect={handleSelect}>
<Tab eventKey="Messages" title="消息">
<div style={{ marginTop: 20 }}>
<Notifications />
</div>
</Tab>
<Tab eventKey="Subscriptions" title="订阅工单">
<Subscriptions />
</Tab>
</Tabs>
)
}