Skip to content

Commit

Permalink
update: keep old route noti center + don't allow change email when si…
Browse files Browse the repository at this point in the history
…gn in email (#2443)
  • Loading branch information
nguyenhoaidanh authored Dec 13, 2023
1 parent c65b7b4 commit 64d3d57
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ export const APP_PATHS = {
IAM_LOGIN: '/login',
IAM_LOGOUT: '/logout',
IAM_CONSENT: '/consent',

DEPRECATED_NOTI_CENTER: '/notification-center/overview',
} as const

export const TERM_FILES_PATH = {
Expand Down
9 changes: 9 additions & 0 deletions src/pages/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { useAutoLogin } from 'hooks/useLogin'
import { useGlobalMixpanelEvents } from 'hooks/useMixpanel'
import useSessionExpiredGlobal from 'hooks/useSessionExpire'
import { useSyncNetworkParamWithStore } from 'hooks/web3/useSyncNetworkParamWithStore'
import { PROFILE_MANAGE_ROUTES } from 'pages/NotificationCenter/const'
import { RedirectPathToSwapV3Network } from 'pages/SwapV3/redirects'
import KyberAIExplore from 'pages/TrueSightV2'
import TruesightFooter from 'pages/TrueSightV2/components/TruesightFooter'
Expand Down Expand Up @@ -365,6 +366,14 @@ export default function App() {
</ProtectedRoute>
}
/>
<Route
path={APP_PATHS.DEPRECATED_NOTI_CENTER}
element={
<ProtectedRoute>
<NotificationCenter redirectRoute={PROFILE_MANAGE_ROUTES.PREFERENCE} />
</ProtectedRoute>
}
/>
<Route path={`${APP_PATHS.GRANT_PROGRAMS}`} element={<GrantProgramPage />} />
<Route path={`${APP_PATHS.GRANT_PROGRAMS}/:slug`} element={<GrantProgramPage />} />

Expand Down
3 changes: 3 additions & 0 deletions src/pages/NotificationCenter/NotificationPreference/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import InputEmailWithVerification from 'pages/NotificationCenter/NotificationPre
import { PROFILE_MANAGE_ROUTES } from 'pages/NotificationCenter/const'
import { useNotify } from 'state/application/hooks'
import { useSessionInfo } from 'state/authen/hooks'
import { useSignedAccountInfo } from 'state/profile/hooks'
import { useIsWhiteListKyberAI } from 'state/user/hooks'
import { pushUnique } from 'utils'
import { isEmailValid } from 'utils/string'
Expand Down Expand Up @@ -141,6 +142,7 @@ function NotificationPreference({ toggleModal = noop }: { toggleModal?: () => vo
const { account } = useActiveWeb3React()
const { userInfo, isLogin } = useSessionInfo()
const { isWhiteList } = useIsWhiteListKyberAI()
const { isSignInEmail } = useSignedAccountInfo()

const { inputEmail, errorInput, onChangeEmail, reset } = useValidateEmail(userInfo?.email)
const [isShowVerify, setIsShowVerify] = useState(false)
Expand Down Expand Up @@ -377,6 +379,7 @@ function NotificationPreference({ toggleModal = noop }: { toggleModal?: () => vo
isVerifiedEmail={!!isVerifiedEmail}
isShowVerify={isShowVerify}
onDismissVerifyModal={onDismissVerifyModal}
disabled={isSignInEmail}
/>
{errorInput && (
<Label style={{ color: errorInput ? theme.red : theme.border, margin: '7px 0px 0px 0px' }}>
Expand Down
3 changes: 2 additions & 1 deletion src/pages/NotificationCenter/Profile/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export default function Profile() {
const [nickname, setNickName] = useState('')
const { signOut } = useLogin()
const navigate = useNavigate()
const { isSignInEth, signedAccount, isSigInGuest } = useSignedAccountInfo()
const { isSignInEth, signedAccount, isSigInGuest, isSignInEmail } = useSignedAccountInfo()
const { totalGuest } = useProfileInfo()
const canSignOut = !isSigInGuest || (isSigInGuest && totalGuest > 1)

Expand Down Expand Up @@ -297,6 +297,7 @@ export default function Profile() {
isVerifiedEmail={!!isVerifiedEmail}
isShowVerify={isShowVerify}
onDismissVerifyModal={onDismissVerifyModal}
disabled={isSignInEmail}
/>
</FormGroup>
</LeftColum>
Expand Down
9 changes: 7 additions & 2 deletions src/pages/NotificationCenter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ const RightColumn = styled.div`
`}
`

function NotificationCenter() {
function NotificationCenter({ redirectRoute }: { redirectRoute?: PROFILE_MANAGE_ROUTES }) {
const isMobile = useMedia(`(max-width: ${MEDIA_WIDTHS.upToMedium}px)`)

return (
<PageWrapper>
<HeaderWrapper>
Expand Down Expand Up @@ -149,7 +150,11 @@ function NotificationCenter() {

<Route
path="*"
element={<Navigate to={`${APP_PATHS.PROFILE_MANAGE}${PROFILE_MANAGE_ROUTES.ALL_NOTIFICATION}`} />}
element={
<Navigate
to={`${APP_PATHS.PROFILE_MANAGE}${redirectRoute || PROFILE_MANAGE_ROUTES.ALL_NOTIFICATION}`}
/>
}
/>
</Routes>
</RightColumn>
Expand Down
1 change: 1 addition & 0 deletions src/state/profile/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ export const useSignedAccountInfo = () => {
isSigInGuest,
isSignInGuestDefault,
isSignInEth,
isSignInEmail,
}
}

Expand Down

0 comments on commit 64d3d57

Please sign in to comment.