|
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { |
| 3 | + DerivLightIcEmailSentIcon, |
| 4 | + DerivLightIcFirewallEmailPasskeyIcon, |
| 5 | + DerivLightIcSpamEmailPasskeyIcon, |
| 6 | + DerivLightIcTypoEmailPasskeyIcon, |
| 7 | + DerivLightIcWrongEmailPasskeyIcon, |
| 8 | +} from '@deriv/quill-icons'; |
| 9 | +import { Button, Modal, Text, useDevice } from '@deriv-com/ui'; |
| 10 | +import './EmailVerificationModal.scss'; |
| 11 | + |
| 12 | +const reasons = [ |
| 13 | + { |
| 14 | + icon: DerivLightIcSpamEmailPasskeyIcon, |
| 15 | + text: 'The email is in your spam folder (sometimes things get lost there).', |
| 16 | + }, |
| 17 | + { |
| 18 | + icon: DerivLightIcWrongEmailPasskeyIcon, |
| 19 | + text: 'You accidentally gave us another email address (usually a work or a personal one instead of the one you meant).', |
| 20 | + }, |
| 21 | + { |
| 22 | + icon: DerivLightIcTypoEmailPasskeyIcon, |
| 23 | + text: 'The email address you entered had a mistake or typo (happens to the best of us).', |
| 24 | + }, |
| 25 | + { |
| 26 | + icon: DerivLightIcFirewallEmailPasskeyIcon, |
| 27 | + text: 'We can’t deliver the email to this address (usually because of firewalls or filtering).', |
| 28 | + }, |
| 29 | +]; |
| 30 | + |
| 31 | +type TEmailVerificationModalProps = { |
| 32 | + isModalOpen: boolean; |
| 33 | + onRequestClose: () => void; |
| 34 | +}; |
| 35 | + |
| 36 | +const EmailVerificationModal = ({ isModalOpen, onRequestClose }: TEmailVerificationModalProps) => { |
| 37 | + const [shouldShowReasons, setShouldShowReasons] = useState<boolean>(false); |
| 38 | + const { isMobile } = useDevice(); |
| 39 | + const emailIconSize = isMobile ? 100 : 128; |
| 40 | + const reasonIconSize = isMobile ? 32 : 36; |
| 41 | + |
| 42 | + return ( |
| 43 | + <Modal |
| 44 | + ariaHideApp={false} |
| 45 | + className='p2p-v2-email-verification-modal' |
| 46 | + isOpen={isModalOpen} |
| 47 | + onRequestClose={onRequestClose} |
| 48 | + > |
| 49 | + <Modal.Header className='mt-2' hideBorder onRequestClose={onRequestClose} /> |
| 50 | + <Modal.Body className='flex flex-col items-center justify-center lg:gap-[2.4rem] gap-8 lg:px-10 lg:pb-10 p-8 pt-0'> |
| 51 | + <DerivLightIcEmailSentIcon height={emailIconSize} width={emailIconSize} /> |
| 52 | + <Text align='center' weight='bold'> |
| 53 | + Has the buyer paid you? |
| 54 | + </Text> |
| 55 | + <Text align='center' size={isMobile ? 'sm' : 'md'}> |
| 56 | + Releasing funds before receiving payment may result in losses. Check your email and follow the |
| 57 | + instructions <strong>within 10 minutes</strong> to release the funds. |
| 58 | + </Text> |
| 59 | + <Button |
| 60 | + className='p2p-v2-email-verification-modal__button' |
| 61 | + onClick={() => setShouldShowReasons(true)} |
| 62 | + variant='ghost' |
| 63 | + > |
| 64 | + I didn’t receive the email |
| 65 | + </Button> |
| 66 | + {shouldShowReasons && ( |
| 67 | + <div className='flex flex-col w-full gap-8'> |
| 68 | + {reasons.map(reason => ( |
| 69 | + <div className='grid grid-cols-[11%_89%] gap-4 items-center' key={reason.text}> |
| 70 | + <reason.icon height={reasonIconSize} width={reasonIconSize} /> |
| 71 | + <Text size='xs'>{reason.text}</Text> |
| 72 | + </div> |
| 73 | + ))} |
| 74 | + <div className='flex justify-center'> |
| 75 | + {/* TODO: Replace 59s with epoch value (verification_next_request) from BE response |
| 76 | + * and disable the button if the epoch value is not reached yet |
| 77 | + */} |
| 78 | + <Button size='md'>Resend email 59s</Button> |
| 79 | + </div> |
| 80 | + </div> |
| 81 | + )} |
| 82 | + </Modal.Body> |
| 83 | + </Modal> |
| 84 | + ); |
| 85 | +}; |
| 86 | + |
| 87 | +export default EmailVerificationModal; |
0 commit comments