forked from inovizz/lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6a34983
commit 00bc309
Showing
9 changed files
with
202 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const NotificationType = { | ||
SHOW_ADD_BOOKS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in Adding Book.' | ||
}, | ||
SHOW_ACCOUNTS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Not getting User Account.' | ||
}, | ||
SHOW_OWNERDETAILS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Not getting Owner Details.' | ||
}, | ||
SHOW_ALL_BOOKS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in getting all books.' | ||
}, | ||
SHOW_MY_BOOKS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in getting my books.' | ||
}, | ||
SHOW_RATE_BOOK_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in rating book.' | ||
}, | ||
SHOW_GET_BORROW_BOOKS_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in borrowing book.' | ||
}, | ||
SHOW_GET_RATE_BOOK_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in getting rate book.' | ||
}, | ||
SHOW_CREATE_ACCOUNT_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in creating account.' | ||
}, | ||
SHOW_ADD_MEMBER_ERROR : { | ||
type : 'error', | ||
title : 'Oops', | ||
text : 'Error, in adding member.' | ||
} | ||
} | ||
|
||
export default NotificationType |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import ReactDOM from 'react-dom'; | ||
import Notifications from 'react-notification-system-redux'; | ||
|
||
class NotifyMe extends React.Component { | ||
componentWillReceiveProps(nextProps) { | ||
if (JSON.stringify(this.props.message) !== JSON.stringify(nextProps.message)) { | ||
const { type } = nextProps.message.message; | ||
switch (type) { | ||
case 'success': | ||
this.dispatchNotification(Notifications.success, 250, nextProps); | ||
case 'error': | ||
this.dispatchNotification(Notifications.error, 250, nextProps); | ||
default: break | ||
} | ||
} | ||
} | ||
dispatchNotification(fn, timeout, nextProps) { | ||
const { title, text } = nextProps.message.message; | ||
const notificationOpts = { | ||
// uid: 'once-please', // you can specify your own uid if required | ||
title: title, | ||
message: text, | ||
position: 'br', | ||
autoDismiss: 0, | ||
action: { | ||
label: 'Close!!', | ||
// callback: () => alert('clicked!') | ||
} | ||
}; | ||
setTimeout(() => { | ||
this.context.store.dispatch(fn(notificationOpts)); | ||
}, timeout); | ||
} | ||
|
||
render() { | ||
const { notifications } = this.props; | ||
|
||
return ( | ||
<div> | ||
<Notifications notifications={notifications} /> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
// export default NotifyMe; | ||
|
||
NotifyMe.contextTypes = { | ||
store: PropTypes.object | ||
}; | ||
|
||
NotifyMe.propTypes = { | ||
notifications: PropTypes.array | ||
}; | ||
|
||
export default connect( | ||
state => ({ notifications: state.notifications }) | ||
)(NotifyMe); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.