import { useState } from 'react'; // material-ui import { Grid, Typography, Stack, Button, Box } from '@mui/material'; import { isORGLoggedIn, } from "utils/Utils"; import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import { FormattedMessage, useIntl } from "react-intl"; import AdsClickRoundedIcon from '@mui/icons-material/AdsClickRounded'; import * as React from "react"; import Loadable from 'components/Loadable'; import * as HttpUtils from "utils/HttpUtils"; import * as UrlUtils from "utils/ApiPathConst"; import * as DateUtils from "utils/DateUtils"; const Message = Loadable(React.lazy(() => import('./Message'))); const Notice = Loadable(React.lazy(() => import('./Notice'))); // import { lazy } from 'react'; const LoadingComponent = Loadable(React.lazy(() => import('../../extra-pages/LoadingComponent'))); import { useNavigate } from "react-router-dom"; // ==============================|| DASHBOARD - DEFAULT ||============================== // const DashboardDefault = () => { const navigate = useNavigate() const intl = useIntl(); const userData = JSON.parse(localStorage.getItem("userData")); const BackgroundHead = { // backgroundColor: '#0d47a1', backgroundImage: `url(${titleBackgroundImg})`, width: '100%', height: '100%', backgroundSize: 'contain', backgroundRepeat: 'no-repeat', backgroundColor: '#0C489E', backgroundPosition: 'right' } const { locale } = intl; const [messageOnReady, setMessageOnReady] = useState(false); const [onNoticeReady, setNoticeOnReady] = useState(false); const [isLoading, setLoding] = useState(true); const [itemList, setItemList] = React.useState([]); const [listData, setListData] = React.useState([]); React.useEffect(() => { loadMessageData() loadNoticeData() localStorage.setItem('searchCriteria',"") }, []); const getWelcomeMsg=()=>{ var current = new Date() var curHr = current.getHours() if (curHr < 12) { return } else if (curHr < 18) { return } else { return } } React.useEffect(() => { // console.log(messageOnReady) // console.log(onNoticeReady) if(messageOnReady&&onNoticeReady){ setLoding(false) // console.log(123) } }, [messageOnReady,onNoticeReady]); const loadMessageData = () => { HttpUtils.get({ url: UrlUtils.GET_MSG_DASHBOARD, onSuccess: function (response) { let list = [] response.map((item) => { list.push( ) }); setItemList(list); setMessageOnReady(true); // console.log('123') }, onError: function (){ // console.log('123') setMessageOnReady(true); } }); // props.setMessageOnReady(true); }; const loadNoticeData = () => { HttpUtils.get({ url: UrlUtils.GET_ANNOUNCE_DASHBOARD, onSuccess: function (response) { setListData(response); setNoticeOnReady(true) }, onError: function () { setNoticeOnReady(true) } }); }; return ( isLoading ?
{/* 我的公共啟事 */} {isORGLoggedIn() ? userData.fullenName: (locale === 'en' ?userData.fullenName: userData.fullchName)}, {getWelcomeMsg()}
:
{/* 我的公共啟事 */} {isORGLoggedIn() ? userData.fullenName: (locale === 'en' ?userData.fullenName: userData.fullchName)}, {getWelcomeMsg()}
); }; export default DashboardDefault;