Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: email link expired modal #70

Merged
merged 4 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.email-link-expired-modal {
@include default-modal;

&__body {
display: flex;
align-items: center;
flex-direction: column;
padding: 2.4rem 2.4rem 0;

@include mobile {
padding: 1.6rem 1.6rem 0;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { DerivLightIcEmailSentExpiredIcon } from '@deriv/quill-icons';
import { Localize } from '@deriv-com/translations';
import { Button, Modal, Text, useDevice } from '@deriv-com/ui';
import './EmailLinkExpiredModal.scss';

type TEmailLinkExpiredModal = {
isModalOpen: boolean;
onClickHandler: () => void;
onRequestClose: () => void;
};

const EmailLinkExpiredModal = ({ isModalOpen, onClickHandler, onRequestClose }: TEmailLinkExpiredModal) => {
const { isMobile } = useDevice();
const iconSize = isMobile ? 96 : 128;
return (
<Modal
ariaHideApp={false}
className='email-link-expired-modal'
isOpen={isModalOpen}
onRequestClose={onRequestClose}
>
<Modal.Header hideBorder onRequestClose={onRequestClose} />
<Modal.Body className='email-link-expired-modal__body'>
<DerivLightIcEmailSentExpiredIcon height={iconSize} width={iconSize} />
<Text align='center' className='flex justify-center mt-[3.6rem]' weight='bold'>
<Localize i18n_default_text='The verification link appears to be invalid. Hit the button below to request for a new one' />
</Text>
</Modal.Body>
<Modal.Footer className='justify-center lg:py-[2.4rem]' hideBorder>
<Button onClick={onClickHandler} size='lg' textSize='sm'>
<Localize i18n_default_text='Get new link' />
</Button>
</Modal.Footer>
</Modal>
);
};

export default EmailLinkExpiredModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import EmailLinkExpiredModal from '../EmailLinkExpiredModal';

const mockProps = {
isModalOpen: true,
onClickHandler: jest.fn(),
onRequestClose: jest.fn(),
};

jest.mock('@deriv-com/ui', () => ({
...jest.requireActual('@deriv-com/ui'),
useDevice: () => ({
isMobile: false,
}),
}));

describe('EmailLinkExpiredModal', () => {
it('should render the modal as expected', () => {
render(<EmailLinkExpiredModal {...mockProps} />);
expect(
screen.getByText(
'The verification link appears to be invalid. Hit the button below to request for a new one'
)
).toBeInTheDocument();
expect(screen.getByText('Get new link')).toBeInTheDocument();
});
it('should handle onClickHandler', async () => {
render(<EmailLinkExpiredModal {...mockProps} />);
const button = screen.getByRole('button', { name: 'Get new link' });
await userEvent.click(button);
expect(mockProps.onClickHandler).toHaveBeenCalledTimes(1);
});
});
1 change: 1 addition & 0 deletions src/components/Modals/EmailLinkExpiredModal/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as EmailLinkExpiredModal } from './EmailLinkExpiredModal';
1 change: 1 addition & 0 deletions src/components/Modals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from './AvailableP2PBalanceModal';
export * from './BlockUnblockUserModal';
export * from './DailyLimitModal';
export * from './EmailLinkBlockedModal';
export * from './EmailLinkExpiredModal';
export * from './EmailLinkVerifiedModal';
export * from './EmailVerificationModal';
export * from './ErrorModal';
Expand Down
Loading