0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

remove console logs and lint

This commit is contained in:
Víctor Losada Hernández
2024-10-23 19:47:12 +02:00
parent 1f7ff4386b
commit 069d054e30
2 changed files with 8 additions and 13 deletions

View File

@@ -7,7 +7,6 @@ import Dialog from '../../../components/dialog.jsx';
const DISMISS_BUTTON = <i className='fas fa-times dismiss' />;
const NotificationPopup = ()=>{
const [notifications, setNotifications] = useState([]);
const [dissmissKeyList, setDismissKeyList] = useState([]);
const [error, setError] = useState(null);
@@ -16,9 +15,8 @@ const NotificationPopup = ()=>{
getNotifications();
}, []);
const getNotifications = async () => {
const getNotifications = async ()=>{
setError(null);
try {
const res = await request.get('/admin/notification/all');
pickActiveNotifications(res.body || []);
@@ -26,30 +24,29 @@ const NotificationPopup = ()=>{
console.log(err);
setError(`Error looking up notifications: ${err?.response?.body?.message || err.message}`);
}
}
};
const pickActiveNotifications = (notifs) => {
const pickActiveNotifications = (notifs)=>{
const now = new Date();
const filteredNotifications = notifs.filter(notification => {
const filteredNotifications = notifs.filter((notification)=>{
const startDate = new Date(notification.startAt);
const stopDate = new Date(notification.stopAt);
const dismissed = localStorage.getItem(notification.dismissKey) ? true : false;
return now >= startDate && now <= stopDate && !dismissed;
});
setNotifications(filteredNotifications);
setDismissKeyList(filteredNotifications.map(notif => notif.dismissKey));
}
setDismissKeyList(filteredNotifications.map((notif)=>notif.dismissKey));
};
const renderNotificationsList = ()=>{
if(error)
return <div className='error'>{error}</div>;
if(error) return <div className='error'>{error}</div>;
return notifications.map((notification)=>(
<li key={notification.dismissKey} >
<em>{notification.title}</em><br />
<p dangerouslySetInnerHTML={{ __html: notification.text }}></p>
</li>
))
));
};
return <Dialog className='notificationPopup' dismisskeys={dissmissKeyList} closeText={DISMISS_BUTTON} >

View File

@@ -143,7 +143,6 @@ router.get('/admin/stats', mw.adminOnly, async (req, res)=>{
router.get('/admin/notification/all', async (req, res, next)=>{
try {
const notifications = await NotificationModel.getAll();
console.log('notifications: ', notifications);
return res.json(notifications);
} 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)=>{
console.table(req.body);
try {
const notification = await NotificationModel.addNotification(req.body);
return res.status(201).json(notification);