diff --git a/src/components/I18nProvider.js b/src/components/I18nProvider.js index 3185ff5..5f71384 100644 --- a/src/components/I18nProvider.js +++ b/src/components/I18nProvider.js @@ -26,6 +26,7 @@ export const I18nProvider = ({ children }) => { setLocale(localStorage.getItem('locale')); } }, []); + useEffect(() => { // Load the messages for the selected locale const fetchMessages = async () => { diff --git a/src/components/RefreshTokenProvider.js b/src/components/RefreshTokenProvider.js index 0978d79..fa73be8 100644 --- a/src/components/RefreshTokenProvider.js +++ b/src/components/RefreshTokenProvider.js @@ -2,7 +2,9 @@ import { createContext, useEffect, useRef, useCallback } from 'react'; import { apiPath } from 'auth/utils'; import { REFRESH_TOKEN } from 'utils/ApiPathConst'; import axios from 'axios'; - +import { + isUserLoggedIn, +} from "utils/Utils"; const RefreshTokenContext = createContext(); const RefreshTokenProvider = ({ children }) => { @@ -55,7 +57,9 @@ const RefreshTokenProvider = ({ children }) => { // console.log('accessToken: ' + localStorage.getItem('accessToken')); // console.log('refreshToken: ' + localStorage.getItem('refreshToken')); if (currentTime >= expiryTime) { - handleRefreshToken(); + if(isUserLoggedIn()){ + handleRefreshToken(); + } } } }, [token]); diff --git a/src/layout/MainLayout/Header/HeaderContent/LocaleSelector.js b/src/layout/MainLayout/Header/HeaderContent/LocaleSelector.js index 1bb266c..a955469 100644 --- a/src/layout/MainLayout/Header/HeaderContent/LocaleSelector.js +++ b/src/layout/MainLayout/Header/HeaderContent/LocaleSelector.js @@ -18,7 +18,7 @@ import Transitions from 'components/@extended/Transitions'; import LanguageIcon from '@mui/icons-material/Language'; import {FormattedMessage} from "react-intl"; import * as React from "react"; -import LocaleContext from "../../../../components/I18nProvider"; +import LocaleContext from "components/I18nProvider"; // ==============================|| HEADER CONTENT - NOTIFICATION ||============================== // diff --git a/src/pages/DemandNote/Search/index.js b/src/pages/DemandNote/Search/index.js index 7f2120e..abd80f0 100644 --- a/src/pages/DemandNote/Search/index.js +++ b/src/pages/DemandNote/Search/index.js @@ -98,7 +98,7 @@ const UserSearchPage_Individual = () => { : - +
diff --git a/src/pages/Organization/SearchPage/index.js b/src/pages/Organization/SearchPage/index.js index 3218eef..9969b27 100644 --- a/src/pages/Organization/SearchPage/index.js +++ b/src/pages/Organization/SearchPage/index.js @@ -71,7 +71,7 @@ const OrganizationSearchPage = () => { : - +
diff --git a/src/pages/Proof/Search_GLD/index.js b/src/pages/Proof/Search_GLD/index.js index ede9572..6de5186 100644 --- a/src/pages/Proof/Search_GLD/index.js +++ b/src/pages/Proof/Search_GLD/index.js @@ -96,7 +96,7 @@ const UserSearchPage_Individual = () => { : -
diff --git a/src/pages/PublicNotice/ListPanel/index.js b/src/pages/PublicNotice/ListPanel/index.js index bbefc26..c15fd37 100644 --- a/src/pages/PublicNotice/ListPanel/index.js +++ b/src/pages/PublicNotice/ListPanel/index.js @@ -108,7 +108,7 @@ const PublicNotice = () => { : - +
diff --git a/src/pages/PublicNotice/Search_GLD/index.js b/src/pages/PublicNotice/Search_GLD/index.js index 68dbe80..0913814 100644 --- a/src/pages/PublicNotice/Search_GLD/index.js +++ b/src/pages/PublicNotice/Search_GLD/index.js @@ -96,7 +96,7 @@ const UserSearchPage_Individual = () => { : - +
diff --git a/src/pages/User/DetailsPage_Organization/index.js b/src/pages/User/DetailsPage_Organization/index.js index 22b45c7..f226ca7 100644 --- a/src/pages/User/DetailsPage_Organization/index.js +++ b/src/pages/User/DetailsPage_Organization/index.js @@ -185,7 +185,7 @@ const UserMaintainPage_Organization = () => { : - +
diff --git a/src/pages/User/SearchPage_Organization/index.js b/src/pages/User/SearchPage_Organization/index.js index 959a250..7dd73ae 100644 --- a/src/pages/User/SearchPage_Organization/index.js +++ b/src/pages/User/SearchPage_Organization/index.js @@ -72,7 +72,7 @@ const UserSearchPage_Organization = () => { : - +
diff --git a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js index 2e6481b..fa984ba 100644 --- a/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js +++ b/src/pages/authentication/ForgotPassword/ForgotPasswordApplyForm.js @@ -15,8 +15,8 @@ import { import { useFormik } from 'formik'; import * as yup from 'yup'; import * as React from "react"; -// import * as HttpUtils from "utils/HttpUtils"; -// import * as UrlUtils from "utils/ApiPathConst"; +import * as HttpUtils from "utils/HttpUtils"; +import * as UrlUtils from "utils/ApiPathConst"; // import * as FieldUtils from "utils/FieldUtils"; import titleBackgroundImg from 'assets/images/dashboard/gazette-bar.png' import ForwardIcon from '@mui/icons-material/Forward'; @@ -60,32 +60,23 @@ const ForgotPasswordApplyForm = () => { }), onSubmit: values => { console.log(values) - navigate('/forgot/password/sent'); - - // HttpUtils.postWithFiles({ - // url: UrlUtils.POST_PUBLIC_NOTICE_APPLY, - // params: { - // id: 0, - // contactPerson: values.contactPerson, - // contactTelNo: { - // countryCode: values.tel_countryCode, - // phoneNumber: values.phoneNumber - // }, - // contactFaxNo: { - // countryCode: values.fax_countryCode, - // faxNumber: values.faxNumber - // }, - // issueId: issueId, - // careOf: values.careOf ? values.careOf: "", - // remarks: values.remarks ? values.remarks : "", - // }, - // // files: [attachment], - // onSuccess: function () { - // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') - // navigate("/publicNotice"); - // // location.reload(); - // } - // }); + HttpUtils.post({ + url: UrlUtils.POST_FORGOT_PASSWORD_EMAIL, + params: { + username: values.username, + }, + // files: [attachment], + onSuccess: function () { + // notifyActionSuccess(intl.formatMessage({id: 'submissionSuccess'}) + '!') + navigate('/forgot/password/sent'); + console.log("jjj") + // location.reload(); + }, + onError:function () { + navigate('/forgot/password/sent'); + console.log("hihihi") + } + }); } }); diff --git a/src/pages/authentication/auth-forms/AuthLoginCustom.js b/src/pages/authentication/auth-forms/AuthLoginCustom.js index 94798c2..67d965c 100644 --- a/src/pages/authentication/auth-forms/AuthLoginCustom.js +++ b/src/pages/authentication/auth-forms/AuthLoginCustom.js @@ -1,7 +1,8 @@ import React, { useEffect, useState, - lazy, useContext + lazy, + // useContext } from 'react'; import { Link as RouterLink } from 'react-router-dom'; import { useNavigate } from 'react-router-dom'; @@ -42,17 +43,17 @@ import { EyeOutlined, EyeInvisibleOutlined } from '@ant-design/icons'; import iAmSmartICon from 'assets/images/icons/icon_iAmSmart.png'; import { useDispatch } from "react-redux"; import { handleLogin } from "auth/index"; -import useJwt from "../../../auth/jwt/useJwt"; +import useJwt from "auth/jwt/useJwt"; import { handleLogoutFunction } from 'auth/index'; import {FormattedMessage, useIntl} from "react-intl"; -import LocaleContext from "../../../components/I18nProvider"; +// import LocaleContext from "components/I18nProvider"; // ============================|| FIREBASE - LOGIN ||============================ // const AuthLoginCustom = () => { const dispatch = useDispatch() const navigate = useNavigate() const intl = useIntl(); - const { setLocale } = useContext(LocaleContext); + // const { setLocaleFromLogin } = useContext(LocaleContext); const [showPassword, setShowPassword] = useState(false); const handleClickShowPassword = () => { @@ -93,15 +94,15 @@ const AuthLoginCustom = () => { // setSuccess(true) // console.log(response.data); if(response.data.type === "GLD"){ - setLocale("en"); + // setLocale("en"); localStorage.setItem('locale','en'); }else{ if (response.data.preferLocale ==="zh_HK"){ - setLocale("zh-HK"); + // setLocale("zh-HK"); localStorage.setItem('locale','zh-HK'); } if (response.data.preferLocale ==="zh-CN"){ - setLocale("zh-CN"); + // setLocale("zh-CN"); localStorage.setItem('locale','zh-CN'); } } diff --git a/src/pages/iAmSmart/AuthCallback/index.js b/src/pages/iAmSmart/AuthCallback/index.js index 1d0e345..bffcef8 100644 --- a/src/pages/iAmSmart/AuthCallback/index.js +++ b/src/pages/iAmSmart/AuthCallback/index.js @@ -50,15 +50,15 @@ const Index = () => { } const data = { ...userData, accessToken: responseData.accessToken, refreshToken: responseData.refreshToken } if(responseData.type === "GLD"){ - setLocale("en"); + // setLocale("en"); localStorage.setItem('locale','en'); }else{ if (responseData.preferLocale ==="zh_HK"){ - setLocale("zh-HK"); + // setLocale("zh-HK"); localStorage.setItem('locale','zh-HK'); } if (responseData.preferLocale ==="zh-CN"){ - setLocale("zh-CN"); + // setLocale("zh-CN"); localStorage.setItem('locale','zh-CN'); } } diff --git a/src/utils/ApiPathConst.js b/src/utils/ApiPathConst.js index 4b9487b..73456ae 100644 --- a/src/utils/ApiPathConst.js +++ b/src/utils/ApiPathConst.js @@ -75,6 +75,7 @@ export const GET_ID = apiPath+'/user/verifyID'; export const GET_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyEmail'; export const GET_FORGOT_PASSWORD_VERIFY_USER_ACCOUNT = apiPath+'/user/verifyForgotPasswordEmail'; export const POST_FORGOT_PASSWORD_NEW_PASSWORD = apiPath+'/user/forgotPasswordNewPassword'; +export const POST_FORGOT_PASSWORD_EMAIL = apiPath+'/user/sendForgotPasswordEmail'; //Public