Skip to content

Commit

Permalink
Feat [ADN-629] Add forgot password button in injection UI (#650)
Browse files Browse the repository at this point in the history
Co-authored-by: jinoosss <[email protected]>
  • Loading branch information
tfrg and jinoosss authored Jan 13, 2025
1 parent 836e36f commit 760e99d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
13 changes: 13 additions & 0 deletions packages/adena-extension/src/common/utils/browser-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,16 @@ export const createPopupWindow = async (popupPath: string, state: object = {}):
});
});
};

export const isExtensionPopup = (): boolean => {
const views = chrome.extension.getViews({ type: 'popup' });
return views.length > 0 && views[0] === window;
};

export const isSeparatePopupWindow = (): boolean => {
if (isExtensionPopup()) {
return false;
}

return window.opener || chrome.extension.getViews({ type: 'popup' }).length === 0;
};
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useState } from 'react';
import styled, { CSSProp, css } from 'styled-components';
import styled, { css, CSSProp } from 'styled-components';

import { Text, Button } from '@components/atoms';
import { isSeparatePopupWindow } from '@common/utils/browser-utils';
import { Button, Text } from '@components/atoms';
import { TitleWithDesc } from '@components/molecules';
import { RoutePath } from '@types';
import useAppNavigate from '@hooks/use-app-navigate';
import { useWalletContext } from '@hooks/use-context';
import mixins from '@styles/mixins';
import useAppNavigate from '@hooks/use-app-navigate';
import { RoutePath } from '@types';

const text = {
title: 'You’re All Set!',
Expand Down Expand Up @@ -41,11 +42,17 @@ export const LaunchAdena = (): JSX.Element => {
if (clicked) {
return;
}

setClicked(true);
if (params.type === 'GOOGLE' || params.type === 'LEDGER') {
window.close();
}

Promise.all([initWallet(), initNetworkMetainfos()]).then(() => {
if (isSeparatePopupWindow()) {
window.close();
}

navigate(RoutePath.Wallet);
setClicked(false);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isAirgapAccount } from 'adena-module';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useLocation, useNavigate } from 'react-router-dom';
import { useRecoilState } from 'recoil';
import styled from 'styled-components';
import styled, { useTheme } from 'styled-components';

import { PasswordValidationError } from '@common/errors';
import { decodeParameter, parseParameters } from '@common/utils/client-utils';
Expand All @@ -13,7 +13,7 @@ import { useAdenaContext, useWalletContext } from '@hooks/use-context';
import { useCurrentAccount } from '@hooks/use-current-account';
import { useLoadAccounts } from '@hooks/use-load-accounts';
import { InjectionMessageInstance } from '@inject/message';
import { Title } from '@pages/popup/certify/login';
import { ForgetPwd, Title } from '@pages/popup/certify/login';
import { WalletState } from '@states';
import mixins from '@styles/mixins';
import { RoutePath } from '@types';
Expand All @@ -29,6 +29,7 @@ const Wrapper = styled.div`
`;

export const ApproveLogin = (): JSX.Element => {
const theme = useTheme();
const navigate = useNavigate();
const location = useLocation();
const { walletService } = useAdenaContext();
Expand Down Expand Up @@ -152,6 +153,8 @@ export const ApproveLogin = (): JSX.Element => {

const approveButtonClick = (): Promise<void> => tryLoginApprove(password);

const onClickForgotButton = (): void => navigate(RoutePath.ForgotPassword);

return (
<>
{state === 'LOGIN' || (state === 'LOADING' && password !== '') ? (
Expand All @@ -165,7 +168,11 @@ export const ApproveLogin = (): JSX.Element => {
error={error !== null}
ref={inputRef}
/>
{error && <ErrorText text={error.message} />}
<ForgetPwd onClick={onClickForgotButton}>
<Text type='body2Reg' color={theme.neutral.a}>
Forgot Password?
</Text>
</ForgetPwd>
<Button fullWidth onClick={approveButtonClick} margin='auto 0px 0px'>
<Text type='body1Bold'>Unlock</Text>
</Button>
Expand Down

0 comments on commit 760e99d

Please sign in to comment.