Skip to content

Commit

Permalink
[WALL]/ Sergei / wall 2698 / create sketch of change investor passwor…
Browse files Browse the repository at this point in the history
…d screens (#11684)

* feat: add scetch of MT5ChangeInvestorPasswordScreens component

* feat: change text size for emailSendContent

* feat: change WalletButton size

* feat: change some button styles

* feat: complete scetch of change investor password screens
  • Loading branch information
sergei-deriv committed Nov 23, 2023
1 parent befa74c commit 9ffa897
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $size-map: (
);

.wallets-button {
display: inline-flex;
display: flex;
justify-content: center;
align-items: center;
gap: 0.8rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const WalletButton: React.FC<WalletButtonProps> = ({
};

const buttonFontSizeMapper = {
lg: 'sm',
lg: 'md',
md: 'sm',
sm: 'xs',
} as const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { WalletsActionScreen } from '../WalletsActionScreen';
import './SentEmailContent.scss';

type TProps = {
description?: string;
platform?: TPlatforms.All;
};

Expand All @@ -36,14 +37,16 @@ const REASONS = [
},
];

const SentEmailContent: React.FC<TProps> = ({ platform }) => {
const SentEmailContent: React.FC<TProps> = ({ description, platform }) => {
const [shouldShowResendEmailReasons, setShouldShowResendEmailReasons] = useState(false);
const [hasCountdownStarted, setHasCountdownStarted] = useState(false);
const { data } = useSettings();
const { mutate: verifyEmail } = useVerifyEmail();
const { isMobile } = useDevice();
const title = PlatformDetails[platform || 'mt5'].title;
const deviceSize = isMobile ? 'lg' : 'md';
const titleSize = 'md';
const descriptionSize = 'sm';
const emailLinkSize = isMobile ? 'lg' : 'md';
const [count, { resetCountdown, startCountdown }] = useCountdown({
countStart: 60,
intervalMs: 1000,
Expand All @@ -56,21 +59,21 @@ const SentEmailContent: React.FC<TProps> = ({ platform }) => {
return (
<div className='wallets-sent-email-content'>
<WalletsActionScreen
description={`Please click on the link in the email to change your ${title} password.`}
descriptionSize={deviceSize}
description={description ?? `Please click on the link in the email to change your ${title} password.`}
descriptionSize={descriptionSize}
icon={<ChangePassword />}
renderButtons={() => (
<WalletButton
onClick={() => {
setShouldShowResendEmailReasons(true);
}}
size={deviceSize}
size={emailLinkSize}
text="Didn't receive the email?"
variant='ghost'
/>
)}
title='We’ve sent you an email'
titleSize={deviceSize}
titleSize={titleSize}
/>
{shouldShowResendEmailReasons && (
<div className='wallets-sent-email-content__reasons'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,26 @@
}
}
}

&__investor-password {
display: flex;
flex-direction: column;
align-items: center;
gap: 2.4rem;

&-fields {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.6rem;
min-width: 32.8rem;
}

&-buttons {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.6rem;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { ModalStepWrapper, Tab, Tabs } from '../../../../components/Base';
import MT5ChangeInvestorPasswordScreens from './MT5ChangeInvestorPasswordScreens';
import MT5ChangePasswordScreens from './MT5ChangePasswordScreens';
import './ChangePassword.scss';

Expand All @@ -12,8 +13,7 @@ const ChangePassword = () => {
<MT5ChangePasswordScreens />
</Tab>
<Tab title='Investor Password'>
{/* TODO: Add Investor Password */}
<></>
<MT5ChangeInvestorPasswordScreens />
</Tab>
</Tabs>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import React, { useState } from 'react';
import {
SentEmailContent,
WalletButton,
WalletPasswordField,
WalletsActionScreen,
WalletText,
} from '../../../../components';
import { useModal } from '../../../../components/ModalProvider';
import useDevice from '../../../../hooks/useDevice';
import MT5PasswordUpdatedIcon from '../../../../public/images/ic-mt5-password-updated.svg';

type TChangeInvestorPasswordScreenIndex = 'emailVerification' | 'introScreen' | 'savedScreen';

const MT5ChangeInvestorPasswordScreens = () => {
const [currentInvestorPassword, setCurrentInvestorPassword] = useState('');
const [newInvestorPassword, setNewInvestorPassword] = useState('');

const [activeScreen, setActiveScreen] = useState<TChangeInvestorPasswordScreenIndex>('introScreen');
const handleClick = (nextScreen: TChangeInvestorPasswordScreenIndex) => setActiveScreen(nextScreen);

const { isMobile } = useDevice();
const { hide } = useModal();

const ChangeInvestorPasswordScreens = {
introScreen: {
bodyText: (
<>
<WalletText size='sm'>
Use this password to grant viewing access to another user. While they may view your trading
account, they will not be able to trade or take any other actions.
</WalletText>
<WalletText size='sm'>
If this is the first time you try to create a password, or you have forgotten your password,
please reset it.
</WalletText>
</>
),
button: (
<div className='wallets-change-password__investor-password'>
<div className='wallets-change-password__investor-password-fields'>
<WalletPasswordField
key='current_password'
label={`Current investor password`}
onChange={e => setCurrentInvestorPassword(e.target.value)}
password={currentInvestorPassword}
/>
<WalletPasswordField
key='new_password'
label={`New investor password`}
onChange={e => setNewInvestorPassword(e.target.value)}
password={newInvestorPassword}
/>
</div>
<div className='wallets-change-password__investor-password-buttons'>
<WalletButton
disabled={currentInvestorPassword.length < 8 || newInvestorPassword.length < 8}
onClick={() => handleClick('savedScreen')}
size={isMobile ? 'lg' : 'md'}
text='Change investor password'
/>
<WalletButton
onClick={() => handleClick('emailVerification')}
size={isMobile ? 'lg' : 'md'}
text='Create or reset investor password'
variant='ghost'
/>
</div>
</div>
),
headingText: undefined,
icon: undefined,
},
savedScreen: {
bodyText: (
<WalletText align='center' size='sm'>
Your investor password has been changed.
</WalletText>
),
button: <WalletButton onClick={() => hide()} size='lg' text='Okay' />,
headingText: 'Password saved',
icon: <MT5PasswordUpdatedIcon />,
},
};

if (activeScreen === 'emailVerification')
return (
<div className='wallets-change-password__sent-email-wrapper'>
<SentEmailContent description='Please click on the link in the email to reset your password.' />
</div>
);

return (
<div className='wallets-change-password__content'>
<WalletsActionScreen
description={ChangeInvestorPasswordScreens[activeScreen].bodyText}
descriptionSize='sm'
icon={ChangeInvestorPasswordScreens[activeScreen].icon}
renderButtons={() => ChangeInvestorPasswordScreens[activeScreen].button}
title={ChangeInvestorPasswordScreens[activeScreen].headingText}
/>
</div>
);
};

export default MT5ChangeInvestorPasswordScreens;
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

1 comment on commit 9ffa897

@vercel
Copy link

@vercel vercel bot commented on 9ffa897 Nov 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

deriv-app – ./

deriv-app.vercel.app
deriv-app.binary.sx
binary.sx
deriv-app-git-master.binary.sx

Please sign in to comment.