Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature(notifications): add time reference to notification messages #47

Merged
merged 1 commit into from
Oct 23, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/components/admin/Notifications.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { Row, Col } from 'react-materialize';
import moment from 'moment';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unable to resolve path to module 'moment' import/no-unresolved


/**
* displays admin notifications
Expand All @@ -16,7 +17,7 @@ const Notifications = (props) => {
>
<p>
{notification.bookTitle} {notification.type}ed
by {notification.username}
by {notification.username} {moment(notification.createdAt).fromNow()}
</p>
</Col>
)
Expand Down
6 changes: 6 additions & 0 deletions server/controllers/books.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,12 @@ export default {
.then(() => {
book.total -= 1;
book.save(); // wait till book is saved before sending response
const notification = new Notification({
type: 'borrow',
bookTitle: book.title,
username: req.user.username,
});
notification.save();
})
.then(() => res.status(200).send({
message: `You have successfully borrowed ${book.title}` +
Expand Down