|
1 | 1 | import { Avatar, Badge, Dropdown, Icon, Layout, Menu } from 'antd'; |
2 | 2 | import { connect } from 'dva'; |
3 | 3 | import Debounce from 'lodash-decorators/debounce'; |
4 | | -import React, { Component } from 'react'; |
| 4 | +import React, { PureComponent } from 'react'; |
5 | 5 |
|
6 | 6 | import { UserInfo } from '../../models/global'; |
7 | 7 | import styles from './Header.module.scss'; |
8 | 8 | import NoticePane from './NoticePane'; |
9 | 9 |
|
10 | 10 | const { ItemGroup } = Menu; |
11 | 11 |
|
12 | | -interface InternalProps { |
| 12 | +interface DvaProps { |
| 13 | + logout: () => void; |
| 14 | + loadMoreNotices: (params?: any) => void; |
| 15 | +} |
| 16 | + |
| 17 | +interface InternalProps extends DvaProps { |
13 | 18 | notices: any[]; |
14 | 19 | userInfo: UserInfo; |
15 | 20 | collapsed: boolean; |
16 | 21 | hasMore: boolean; |
17 | 22 | fetchingNotices: boolean; |
18 | | - loadMoreNotices: (params?: any) => void; |
19 | 23 | onCollapse: (collapsed: boolean) => void; |
20 | 24 | } |
21 | 25 |
|
22 | 26 | interface InternalState { |
23 | 27 | showNoticePane: boolean; |
24 | 28 | } |
25 | 29 |
|
26 | | -export class Header extends Component<InternalProps, InternalState> { |
| 30 | +export class Header extends PureComponent<InternalProps, InternalState> { |
27 | 31 | private isFullScreen = false; |
28 | 32 |
|
29 | 33 | private constructor(props: InternalProps) { |
@@ -57,7 +61,7 @@ export class Header extends Component<InternalProps, InternalState> { |
57 | 61 | } |
58 | 62 |
|
59 | 63 | public signOut() { |
60 | | - // TODO: Need to finish sign out logic |
| 64 | + this.props.logout(); |
61 | 65 | } |
62 | 66 |
|
63 | 67 | public onVisibleChange(visible: boolean) { |
@@ -139,6 +143,9 @@ const mapDispatchToProps = (dispatch: any) => { |
139 | 143 | payload: collapsed, |
140 | 144 | }); |
141 | 145 | }, |
| 146 | + logout: () => { |
| 147 | + dispatch({type: 'global/logout'}); |
| 148 | + }, |
142 | 149 | loadMoreNotices: (params?: any) => { |
143 | 150 | dispatch({ |
144 | 151 | type: 'global/fetchNotifications', |
|
0 commit comments