forked from deriv-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[account-v2]/likhith/coj-706/created accordion and modal component (d…
…eriv-com#14676) * feat: created accordion and modal component * fix: incorporated code review comments * feat: incoprorated config for POO * feat: incoprorated config for POO * feat: incoprorated config for POO * fix: CI issues * Merge branch 'master' into likhith/COJ-709/POO-components * Merge branch 'master' into likhith/COJ-709/POO-components * Merge branch 'master' into likhith/COJ-709/POO-components * chore: update import for useOnClickOutside hook from deriv-com/ui to usehooks-ts (#74) * feat: added hook to generate POO data * Merge branch 'master' into likhith/COJ-709/POO-components * fix: incorporated review comments * feat: added util functions * fix: types issue * fix: removed unused import * fix: upgraded quill icons version * chore: refactored config * chore: added testcases * fix: incorporated review comment * fix: updated package version * fix: incorporated Snoar cloud suggestions * fix: element ref missing issue * fix: incorporate review comment * fix: modified config --------- Co-authored-by: Aum Bhatt <125039206+aum-deriv@users.noreply.github.com>
- Loading branch information
1 parent
b1e97f2
commit 71c6056
Showing
28 changed files
with
967 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
167 changes: 167 additions & 0 deletions
167
packages/account-v2/src/constants/paymentMethodsConfig.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
import { | ||
DerivLightWalletIcon, | ||
IconTypes, | ||
PaymentMethodAdvcashBrandDarkIcon, | ||
PaymentMethodAdvcashBrandIcon, | ||
PaymentMethodAstropayBrandDarkIcon, | ||
PaymentMethodAstropayBrandIcon, | ||
PaymentMethodBeyonicBrandIcon, | ||
PaymentMethodBoletoBrandIcon, | ||
PaymentMethodBoletoWhiteIcon, | ||
PaymentMethodJetonBrandIcon, | ||
PaymentMethodMastercardBrandDarkIcon, | ||
PaymentMethodMastercardBrandIcon, | ||
PaymentMethodNetellerBrandIcon, | ||
PaymentMethodNetellerWhiteIcon, | ||
PaymentMethodOnlinenairaBrandDarkIcon, | ||
PaymentMethodOnlinenairaBrandIcon, | ||
PaymentMethodSkrillBrandIcon, | ||
PaymentMethodSkrillWhiteIcon, | ||
PaymentMethodSticpayBrandIcon, | ||
PaymentMethodVisaBrandIcon, | ||
PaymentMethodVisaWhiteIcon, | ||
} from '@deriv/quill-icons'; | ||
import { TPaymentMethod } from 'src/types'; | ||
|
||
/* eslint-disable sonarjs/no-duplicate-string */ | ||
export const PAYMENT_METHOD_IDENTIFIER = Object.freeze({ | ||
accountID: 'account_id', | ||
accountNumber: 'account_number', | ||
bankAccountNumber: 'bank_account_number', | ||
cardNumber: 'card_number', | ||
email: 'email_address', | ||
mobileNumber: 'mobile_number', | ||
userID: 'user_id', | ||
}); | ||
|
||
export const getPaymentMethodsConfig = () => ({ | ||
advcash: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.email, | ||
inputLabel: 'Email address', | ||
}, | ||
astropay: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.accountNumber, | ||
inputLabel: 'Account number', | ||
}, | ||
beyonic: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.mobileNumber, | ||
inputLabel: 'Mobile number', | ||
}, | ||
'boleto (d24 voucher)': { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.bankAccountNumber, | ||
inputLabel: 'Bank account number', | ||
}, | ||
jeton: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.accountNumber, | ||
inputLabel: 'Account number', | ||
}, | ||
mastercard: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.cardNumber, | ||
inputLabel: 'Card number', | ||
}, | ||
neteller: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.email, | ||
inputLabel: 'Email address', | ||
}, | ||
onlinenaira: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.accountID, | ||
inputLabel: 'Account ID', | ||
}, | ||
other: { | ||
identifier: 'none', | ||
inputLabel: null, | ||
}, | ||
pix: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.userID, | ||
inputLabel: 'User ID', | ||
}, | ||
skrill: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.email, | ||
inputLabel: 'Email address', | ||
}, | ||
sticpay: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.email, | ||
inputLabel: 'Email address', | ||
}, | ||
visa: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.cardNumber, | ||
inputLabel: 'Card number', | ||
}, | ||
webmoney: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.accountNumber, | ||
inputLabel: 'Account number', | ||
}, | ||
zingpay: { | ||
identifier: PAYMENT_METHOD_IDENTIFIER.bankAccountNumber, | ||
inputLabel: 'Bank account number', | ||
}, | ||
}); | ||
|
||
type TPaymentMethodIcon = Record<TPaymentMethod, { dark: IconTypes; light: IconTypes }>; | ||
|
||
export const getPaymentMethodIcon: TPaymentMethodIcon = { | ||
advcash: { | ||
dark: PaymentMethodAdvcashBrandDarkIcon, | ||
light: PaymentMethodAdvcashBrandIcon, | ||
}, | ||
astropay: { | ||
dark: PaymentMethodAstropayBrandDarkIcon, | ||
light: PaymentMethodAstropayBrandIcon, | ||
}, | ||
beyonic: { | ||
dark: PaymentMethodBeyonicBrandIcon, | ||
light: PaymentMethodBeyonicBrandIcon, | ||
}, | ||
'boleto (d24 voucher)': { | ||
dark: PaymentMethodBoletoWhiteIcon, | ||
light: PaymentMethodBoletoBrandIcon, | ||
}, | ||
jeton: { | ||
dark: PaymentMethodJetonBrandIcon, | ||
light: PaymentMethodJetonBrandIcon, | ||
}, | ||
mastercard: { | ||
dark: PaymentMethodMastercardBrandDarkIcon, | ||
light: PaymentMethodMastercardBrandIcon, | ||
}, | ||
neteller: { | ||
dark: PaymentMethodNetellerWhiteIcon, | ||
light: PaymentMethodNetellerBrandIcon, | ||
}, | ||
onlinenaira: { | ||
dark: PaymentMethodOnlinenairaBrandDarkIcon, | ||
light: PaymentMethodOnlinenairaBrandIcon, | ||
}, | ||
other: { | ||
// TODO: Change this icon once actual icon is available | ||
dark: DerivLightWalletIcon, | ||
light: DerivLightWalletIcon, | ||
}, | ||
pix: { | ||
// TODO: Change this icon once actual icon is available | ||
dark: DerivLightWalletIcon, | ||
light: DerivLightWalletIcon, | ||
}, | ||
skrill: { | ||
dark: PaymentMethodSkrillWhiteIcon, | ||
light: PaymentMethodSkrillBrandIcon, | ||
}, | ||
sticpay: { | ||
dark: PaymentMethodSticpayBrandIcon, | ||
light: PaymentMethodSticpayBrandIcon, | ||
}, | ||
visa: { | ||
dark: PaymentMethodVisaWhiteIcon, | ||
light: PaymentMethodVisaBrandIcon, | ||
}, | ||
webmoney: { | ||
// TODO: Change this icon once actual icon is available | ||
dark: DerivLightWalletIcon, | ||
light: DerivLightWalletIcon, | ||
}, | ||
zingpay: { | ||
// TODO: Change this icon once actual icon is available | ||
dark: DerivLightWalletIcon, | ||
light: DerivLightWalletIcon, | ||
}, | ||
}; |
26 changes: 26 additions & 0 deletions
26
packages/account-v2/src/containers/MaskCardModal/MaskCardModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { DerivLightCreditCardSampleIcon } from '@deriv/quill-icons'; | ||
import { Modal, Text } from '@deriv-com/ui'; | ||
|
||
type TMaskCardModal = { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
}; | ||
|
||
export const MaskCardModal = ({ isOpen, onClose }: TMaskCardModal) => { | ||
return ( | ||
<Modal className='w-[440px]' isOpen={isOpen}> | ||
<Modal.Header onRequestClose={onClose}> | ||
<Text as='h3' size='md' weight='bold'> | ||
How to mask your card? | ||
</Text> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Text as='p' className='pt-20 pb-24 px-24' size='sm'> | ||
Black out digits 7 to 12 of the card number that’s shown on the front of your debit/credit card. | ||
</Text> | ||
<DerivLightCreditCardSampleIcon height={120} width={120} /> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; |
47 changes: 47 additions & 0 deletions
47
packages/account-v2/src/containers/MaskCardModal/__tests__/MaskCardModal.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
import { Modal } from '@deriv-com/ui'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import { ACCOUNT_MODAL_REF } from 'src/constants'; | ||
import { MaskCardModal } from '../MaskCardModal'; | ||
|
||
describe('MaskCardModal', () => { | ||
let elModalRoot: HTMLElement; | ||
|
||
beforeAll(() => { | ||
elModalRoot = document.createElement('div'); | ||
elModalRoot.setAttribute('id', ACCOUNT_MODAL_REF.replace('#', '')); | ||
document.body.appendChild(elModalRoot); | ||
Modal.setAppElement(ACCOUNT_MODAL_REF); | ||
}); | ||
|
||
afterAll(() => { | ||
document.body.removeChild(elModalRoot); | ||
}); | ||
|
||
it('should render correctly with the modal open', () => { | ||
const isOpen = true; | ||
const onClose = jest.fn(); | ||
|
||
render(<MaskCardModal isOpen={isOpen} onClose={onClose} />); | ||
|
||
expect(screen.getByText('How to mask your card?')).toBeInTheDocument(); | ||
expect( | ||
screen.getByText( | ||
'Black out digits 7 to 12 of the card number that’s shown on the front of your debit/credit card.' | ||
) | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should close the modal when close icon is clicked', () => { | ||
const isOpen = true; | ||
const onClose = jest.fn(); | ||
|
||
render(<MaskCardModal isOpen={isOpen} onClose={onClose} />); | ||
|
||
const elCloseIcon = screen.getByTestId('dt-close-icon'); | ||
userEvent.click(elCloseIcon); | ||
|
||
expect(onClose).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.