From 4d91e63dcb0b36292da5e5361d58186a235bebf3 Mon Sep 17 00:00:00 2001 From: tianlinzhong <673359306@qq.com> Date: Fri, 5 Nov 2021 10:06:19 +0800 Subject: [PATCH] solve the bug --- .../MyEMS/Notification/Notification.js | 3 +- .../components/navbar/NotificationDropdown.js | 51 +++++-------------- 2 files changed, 15 insertions(+), 39 deletions(-) diff --git a/web/src/components/MyEMS/Notification/Notification.js b/web/src/components/MyEMS/Notification/Notification.js index cc4c4c1f..62aa3a62 100644 --- a/web/src/components/MyEMS/Notification/Notification.js +++ b/web/src/components/MyEMS/Notification/Notification.js @@ -260,8 +260,7 @@ const Notification = ({ setRedirect, setRedirectUrl, t }) => { }, body: JSON.stringify({ "data": { - "status": '' + - '', + "status": 'acknowledged', "reply": 'ok' } }), diff --git a/web/src/components/navbar/NotificationDropdown.js b/web/src/components/navbar/NotificationDropdown.js index 53566e13..408faabe 100644 --- a/web/src/components/navbar/NotificationDropdown.js +++ b/web/src/components/navbar/NotificationDropdown.js @@ -1,46 +1,27 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import classNames from 'classnames'; -import React, {useEffect, useState} from 'react'; +import React, { useEffect, useState } from 'react'; import { Link } from 'react-router-dom'; import { Card, Dropdown, DropdownMenu, DropdownToggle } from 'reactstrap'; import ListGroup from 'reactstrap/es/ListGroup'; import ListGroupItem from 'reactstrap/es/ListGroupItem'; -// import { rawEarlierNotifications, rawNewNotifications } from '../../data/notification/notification'; -import {getCookieValue, isIterableArray} from '../../helpers/utils'; +import { rawEarlierNotifications, rawNewNotifications } from '../../data/notification/notification'; +import { isIterableArray } from '../../helpers/utils'; import useFakeFetch from '../../hooks/useFakeFetch'; import FalconCardHeader from '../common/FalconCardHeader'; import Notification from '../notification/Notification'; import { withTranslation } from 'react-i18next'; -import {APIBaseURL} from "../../config"; -import {createCookie , getPaginationArray} from '../../helpers/utils'; +import { APIBaseURL } from "../../config"; import moment from 'moment'; -import createMarkup from '../../helpers/createMarkup'; -import {toast} from "react-toastify"; -import {notifications} from "../../data/notification/notification"; +import { toast } from "react-toastify"; +import { getCookieValue } from '../../helpers/utils'; -const NotificationDropdown = ({ setRedirect, setRedirectUrl,t }) => { - let current_moment = moment(); - useEffect(() => { - let is_logged_in = getCookieValue('is_logged_in'); - let user_name = getCookieValue('user_name'); - let user_display_name = getCookieValue('user_display_name'); - let user_uuid = getCookieValue('user_uuid'); - let token = getCookieValue('token'); - if ((is_logged_in === null || !is_logged_in)) { - setRedirectUrl(`/authentication/basic/login`); - setRedirect(true); - } else { - // update expires time of cookies - createCookie('is_logged_in', true, 1000 * 60 * 60 * 8); - createCookie('user_name', user_name, 1000 * 60 * 60 * 8); - createCookie('user_display_name', user_display_name, 1000 * 60 * 60 * 8); - createCookie('user_uuid', user_uuid, 1000 * 60 * 60 * 8); - createCookie('token', token, 1000 * 60 * 60 * 8); - } - }); +const NotificationDropdown = ({ t }) => { + // State const [rawNewNotificationschild, setRawNewNotificationschild] = useState([]); const [isOpen, setIsOpen] = useState(false); const [isAllRead, setIsAllRead] = useState(false); + useEffect(() => { let isResponseOK = false; fetch(APIBaseURL + '/webmessagesnew', { @@ -93,6 +74,7 @@ const NotificationDropdown = ({ setRedirect, setRedirectUrl,t }) => { console.log("test"); console.log(rawNewNotificationschild); + // Handler const handleToggle = e => { e.preventDefault(); @@ -137,6 +119,7 @@ const NotificationDropdown = ({ setRedirect, setRedirectUrl,t }) => { }); }; + return ( { -
{t('notification_NEW')}
+
{t('notification_NEW')}
{isIterableArray(rawNewNotificationschild) && rawNewNotificationschild.map((notification, index) => ( - + ))} - {/*
{t('notification_EARLIER')}
*/} - {/*{isIterableArray(rawNewNotificationschild) &&*/} - {/* rawNewNotificationschild.map((notification, index) => (*/} - {/* */} - {/* */} - {/* */} - {/* ))}*/} +