require('./notificationLookup.less'); const React = require('react'); const createClass = require('create-react-class'); const cx = require('classnames'); const request = require('superagent'); const Moment = require('moment'); const NotificationLookup = createClass({ getDefaultProps() { return {}; }, getInitialState() { return { query : '', foundNotification : null, searching : false, error : null }; }, handleChange(e){ this.setState({ query: e.target.value }); }, lookup(){ this.setState({ searching: true, error: null }); request.get(`/admin/notification/lookup/${this.state.query}`) .then((res)=>this.setState({ foundNotification: res.body })) .catch((err)=>this.setState({ error: err })) .finally(()=>this.setState({ searching: false })); }, renderFoundNotification(){ const notification = this.state.foundnotification; return
Key
{notification.dismissKey}
Title
{notification.title || 'No Title'}
Text
{notification.text || 'No Text'}
Created
{Moment(notification.createdAt).fromNow()}
Start
{Moment(notification.startAt).fromNow() || 'No Start Time'}
Created
{Moment(notification.stopAt).fromNow() || 'No End Time'}
; }, render(){ return

Notification Lookup

{this.state.error &&
{this.state.error.toString()}
} {this.state.foundNotification ? this.renderFoundNotification() :
No notification found.
}
; } }); module.exports = NotificationLookup;