mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 05:32:41 +00:00
remove console logs and lint
This commit is contained in:
@@ -7,7 +7,6 @@ import Dialog from '../../../components/dialog.jsx';
|
|||||||
const DISMISS_BUTTON = <i className='fas fa-times dismiss' />;
|
const DISMISS_BUTTON = <i className='fas fa-times dismiss' />;
|
||||||
|
|
||||||
const NotificationPopup = ()=>{
|
const NotificationPopup = ()=>{
|
||||||
|
|
||||||
const [notifications, setNotifications] = useState([]);
|
const [notifications, setNotifications] = useState([]);
|
||||||
const [dissmissKeyList, setDismissKeyList] = useState([]);
|
const [dissmissKeyList, setDismissKeyList] = useState([]);
|
||||||
const [error, setError] = useState(null);
|
const [error, setError] = useState(null);
|
||||||
@@ -16,9 +15,8 @@ const NotificationPopup = ()=>{
|
|||||||
getNotifications();
|
getNotifications();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const getNotifications = async () => {
|
const getNotifications = async ()=>{
|
||||||
setError(null);
|
setError(null);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await request.get('/admin/notification/all');
|
const res = await request.get('/admin/notification/all');
|
||||||
pickActiveNotifications(res.body || []);
|
pickActiveNotifications(res.body || []);
|
||||||
@@ -26,30 +24,29 @@ const NotificationPopup = ()=>{
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
setError(`Error looking up notifications: ${err?.response?.body?.message || err.message}`);
|
setError(`Error looking up notifications: ${err?.response?.body?.message || err.message}`);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
const pickActiveNotifications = (notifs) => {
|
const pickActiveNotifications = (notifs)=>{
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const filteredNotifications = notifs.filter(notification => {
|
const filteredNotifications = notifs.filter((notification)=>{
|
||||||
const startDate = new Date(notification.startAt);
|
const startDate = new Date(notification.startAt);
|
||||||
const stopDate = new Date(notification.stopAt);
|
const stopDate = new Date(notification.stopAt);
|
||||||
const dismissed = localStorage.getItem(notification.dismissKey) ? true : false;
|
const dismissed = localStorage.getItem(notification.dismissKey) ? true : false;
|
||||||
return now >= startDate && now <= stopDate && !dismissed;
|
return now >= startDate && now <= stopDate && !dismissed;
|
||||||
});
|
});
|
||||||
setNotifications(filteredNotifications);
|
setNotifications(filteredNotifications);
|
||||||
setDismissKeyList(filteredNotifications.map(notif => notif.dismissKey));
|
setDismissKeyList(filteredNotifications.map((notif)=>notif.dismissKey));
|
||||||
}
|
};
|
||||||
|
|
||||||
const renderNotificationsList = ()=>{
|
const renderNotificationsList = ()=>{
|
||||||
if(error)
|
if(error) return <div className='error'>{error}</div>;
|
||||||
return <div className='error'>{error}</div>;
|
|
||||||
|
|
||||||
return notifications.map((notification)=>(
|
return notifications.map((notification)=>(
|
||||||
<li key={notification.dismissKey} >
|
<li key={notification.dismissKey} >
|
||||||
<em>{notification.title}</em><br />
|
<em>{notification.title}</em><br />
|
||||||
<p dangerouslySetInnerHTML={{ __html: notification.text }}></p>
|
<p dangerouslySetInnerHTML={{ __html: notification.text }}></p>
|
||||||
</li>
|
</li>
|
||||||
))
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
return <Dialog className='notificationPopup' dismisskeys={dissmissKeyList} closeText={DISMISS_BUTTON} >
|
return <Dialog className='notificationPopup' dismisskeys={dissmissKeyList} closeText={DISMISS_BUTTON} >
|
||||||
|
|||||||
@@ -143,7 +143,6 @@ router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
|
|||||||
router.get('/admin/notification/all', async (req, res, next)=>{
|
router.get('/admin/notification/all', async (req, res, next)=>{
|
||||||
try {
|
try {
|
||||||
const notifications = await NotificationModel.getAll();
|
const notifications = await NotificationModel.getAll();
|
||||||
console.log('notifications: ', notifications);
|
|
||||||
return res.json(notifications);
|
return res.json(notifications);
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -153,7 +152,6 @@ router.get('/admin/notification/all', async (req, res, next)=>{
|
|||||||
});
|
});
|
||||||
|
|
||||||
router.post('/admin/notification/add', mw.adminOnly, async (req, res, next)=>{
|
router.post('/admin/notification/add', mw.adminOnly, async (req, res, next)=>{
|
||||||
console.table(req.body);
|
|
||||||
try {
|
try {
|
||||||
const notification = await NotificationModel.addNotification(req.body);
|
const notification = await NotificationModel.addNotification(req.body);
|
||||||
return res.status(201).json(notification);
|
return res.status(201).json(notification);
|
||||||
|
|||||||
Reference in New Issue
Block a user