@@ -6,15 +6,21 @@ import * as NotificationInterfaces from 'app/types/Notification';
6
6
import classnames from 'classnames' ;
7
7
import * as React from 'react' ;
8
8
import { Col , Grid , Row } from 'react-bootstrap' ;
9
+ import ReactPaginate from 'react-paginate' ;
10
+ import { faCaretLeft , faCaretRight } from '@fortawesome/free-solid-svg-icons' ;
11
+
9
12
// tslint:disable-next-line
10
13
11
14
export class Notification extends React . Component <
12
15
NotificationInterfaces . Props ,
13
16
NotificationInterfaces . State
14
17
> {
18
+ private static paginationSize = 6 ;
19
+
15
20
constructor ( props : NotificationInterfaces . Props ) {
16
21
super ( props ) ;
17
22
this . state = {
23
+ offset : 0 ,
18
24
activeNotificationTab : NotificationInterfaces . NotificationTabType . ALL ,
19
25
tabType : NotificationInterfaces . TabType . NOTIFICATIONS ,
20
26
} ;
@@ -24,6 +30,12 @@ export class Notification extends React.Component<
24
30
this . props . getAllGlobalAnnouncements ( ) ;
25
31
}
26
32
33
+ public handlePageClick = ( data : { selected : number } ) => {
34
+ this . setState ( {
35
+ offset : Math . ceil ( data . selected * Notification . paginationSize ) ,
36
+ } ) ;
37
+ } ;
38
+
27
39
public render ( ) {
28
40
const { activeNotificationTab, tabType } = this . state ;
29
41
const { announcements, notifications, deleteNotificationType, deleteNotification } = this . props ;
@@ -47,6 +59,7 @@ export class Notification extends React.Component<
47
59
}
48
60
} ) ;
49
61
62
+
50
63
return (
51
64
< Grid fluid = { true } className = { classnames ( styles . Notification ) } >
52
65
< Row className = "justify-content-between py-2 px-3" >
@@ -151,17 +164,48 @@ export class Notification extends React.Component<
151
164
</ div >
152
165
</ Row >
153
166
< Row className = { classnames ( 'mb-2' , styles . notificationWrap ) } >
154
- { activeNotifications . map ( ( { id, title, content, type, createdAt } ) => (
155
- < NotificationElement
156
- createdAt = { createdAt }
157
- key = { id }
158
- id = { id }
159
- title = { title }
160
- content = { content }
161
- type = { type }
162
- deleteNotification = { deleteNotification }
167
+ < Col
168
+ className = "d-flex justify-content-center"
169
+ style = { { width : '100vw' , margin : '5px' } }
170
+ >
171
+ < ReactPaginate
172
+ previousLabel = {
173
+ < span >
174
+ < FontAwesomeIcon icon = { faCaretLeft } /> < FontAwesomeIcon icon = { faCaretLeft } />
175
+ </ span >
176
+ }
177
+ nextLabel = {
178
+ < span >
179
+ < FontAwesomeIcon icon = { faCaretRight } /> { ' ' }
180
+ < FontAwesomeIcon icon = { faCaretRight } />
181
+ </ span >
182
+ }
183
+ breakLabel = { '...' }
184
+ breakClassName = { 'break-me' }
185
+ pageCount = { Math . max ( activeNotifications . length / Notification . paginationSize ) }
186
+ marginPagesDisplayed = { 1 }
187
+ pageClassName = { 'atag' }
188
+ pageRangeDisplayed = { 2 }
189
+ activeLinkClassName = { 'active' }
190
+ onPageChange = { this . handlePageClick }
191
+ containerClassName = { 'pagination' }
192
+ activeClassName = { 'active' }
163
193
/>
164
- ) ) }
194
+ </ Col >
195
+ { activeNotifications . map ( ( { id, title, content, type, createdAt } , index ) =>
196
+ index >= this . state . offset &&
197
+ index <= this . state . offset + Notification . paginationSize - 1 ? (
198
+ < NotificationElement
199
+ createdAt = { createdAt }
200
+ key = { id }
201
+ id = { id }
202
+ title = { title }
203
+ content = { content }
204
+ type = { type }
205
+ deleteNotification = { deleteNotification }
206
+ />
207
+ ) : null ,
208
+ ) }
165
209
</ Row >
166
210
</ >
167
211
) : (
0 commit comments