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.
[Cashier-V2] george / FEQ-1955 / Implement Payment Agent Withdrawal c…
…omponents (deriv-com#14284) * feat(cashier-v2): ✨ add Payment agent withdarwal components * refactor(cashier-v2): 🎨 chore refactoring
- Loading branch information
1 parent
a40f052
commit 1d2e59c
Showing
27 changed files
with
475 additions
and
26 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
1 change: 1 addition & 0 deletions
1
...ymentAgent/components/PaymentAgentCard/components/PaymentAgentCardDepositDetails/index.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 @@ | ||
export { default as PaymentAgentCardDepositDetails } from './PaymentAgentCardDepositDetails'; |
1 change: 0 additions & 1 deletion
1
.../lib/PaymentAgent/components/PaymentAgentCard/components/PaymentAgentCardDetails/index.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...Card/components/PaymentAgentCardWithdrawalForm/PaymentAgentCardWithdrawalForm.module.scss
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,15 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.6rem; | ||
padding-top: 3.2rem; | ||
} | ||
|
||
.form { | ||
display: flex; | ||
|
||
@include mobile-cashier-v2 { | ||
flex-direction: column; | ||
gap: 1.6rem; | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
...entAgentCard/components/PaymentAgentCardWithdrawalForm/PaymentAgentCardWithdrawalForm.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,90 @@ | ||
import React from 'react'; | ||
import { Field, FieldProps, Form, Formik } from 'formik'; | ||
import { Button, Input, Text } from '@deriv-com/ui'; | ||
import { FormatUtils } from '@deriv-com/utils'; | ||
import type { THooks } from '../../../../../../hooks/types'; | ||
import type { TCurrency } from '../../../../../../types'; | ||
import styles from './PaymentAgentCardWithdrawalForm.module.scss'; | ||
|
||
type TPaymentAgentCardWithdrawalFormProps = { | ||
paymentAgent: THooks.PaymentAgentList[number]; | ||
}; | ||
|
||
type TWithdrawalLimitsProps = { | ||
currency: TCurrency; | ||
maxWithdrawalLimit: THooks.PaymentAgentList[number]['max_withdrawal']; | ||
minWithdrawalLimit: THooks.PaymentAgentList[number]['min_withdrawal']; | ||
}; | ||
|
||
const WithdrawalLimits: React.FC<TWithdrawalLimitsProps> = ({ currency, maxWithdrawalLimit, minWithdrawalLimit }) => { | ||
const minLimit = `${FormatUtils.formatMoney(Number(minWithdrawalLimit), { currency })} ${currency}`; | ||
const maxLimit = `${FormatUtils.formatMoney(Number(maxWithdrawalLimit), { currency })} ${currency}`; | ||
|
||
return ( | ||
<Text color='less-prominent' size='xs'> | ||
Withdrawal limits: {minLimit}-{maxLimit} | ||
</Text> | ||
); | ||
}; | ||
|
||
const PaymentAgentCardWithdrawalForm: React.FC<TPaymentAgentCardWithdrawalFormProps> = ({ paymentAgent }) => { | ||
const { currencies, max_withdrawal: maxWithdrawalLimit, min_withdrawal: minWithdrawalLimit } = paymentAgent; | ||
const onSubmitHandler = () => undefined; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<Text as='p' size='sm' weight='bold'> | ||
Withdrawal amount | ||
</Text> | ||
<Formik | ||
initialValues={{ | ||
amount: '', | ||
}} | ||
onSubmit={onSubmitHandler} | ||
> | ||
{({ errors, isSubmitting, isValid, touched, values }) => { | ||
return ( | ||
<Form className={styles.form} noValidate> | ||
<Field name='amount'> | ||
{({ field }: FieldProps) => ( | ||
<Input | ||
{...field} | ||
autoComplete='off' | ||
error={touched.amount && Boolean(errors.amount)} | ||
isFullWidth | ||
label='Enter amount' | ||
maxLength={30} | ||
message={ | ||
<WithdrawalLimits | ||
currency={currencies as TCurrency} | ||
maxWithdrawalLimit={maxWithdrawalLimit} | ||
minWithdrawalLimit={minWithdrawalLimit} | ||
/> | ||
} | ||
required | ||
rightPlaceholder={ | ||
<Text as='span' size='sm'> | ||
{paymentAgent.currencies} | ||
</Text> | ||
} | ||
type='text' | ||
/> | ||
)} | ||
</Field> | ||
<Button | ||
disabled={!isValid || isSubmitting || !values.amount} | ||
size='lg' | ||
textSize='sm' | ||
type='submit' | ||
> | ||
Continue | ||
</Button> | ||
</Form> | ||
); | ||
}} | ||
</Formik> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PaymentAgentCardWithdrawalForm; |
1 change: 1 addition & 0 deletions
1
...ymentAgent/components/PaymentAgentCard/components/PaymentAgentCardWithdrawalForm/index.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 @@ | ||
export { default as PaymentAgentCardWithdrawalForm } from './PaymentAgentCardWithdrawalForm'; |
5 changes: 3 additions & 2 deletions
5
packages/cashier-v2/src/lib/PaymentAgent/components/PaymentAgentCard/components/index.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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { PaymentAgentCardDepositDetails } from './PaymentAgentCardDepositDetails'; | ||
import { PaymentAgentCardDescription } from './PaymentAgentCardDescription'; | ||
import { PaymentAgentCardDetails } from './PaymentAgentCardDetails'; | ||
import { PaymentAgentCardWithdrawalForm } from './PaymentAgentCardWithdrawalForm'; | ||
|
||
export { PaymentAgentCardDescription, PaymentAgentCardDetails }; | ||
export { PaymentAgentCardDepositDetails, PaymentAgentCardDescription, PaymentAgentCardWithdrawalForm }; |
28 changes: 28 additions & 0 deletions
28
...ponents/PaymentAgentUnlistedWithdrawalForm/PaymentAgentUnlistedWithdrawalForm.module.scss
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,28 @@ | ||
.container { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2.4rem; | ||
width: 100%; | ||
max-width: 58.8rem; | ||
margin: 0 auto; | ||
} | ||
|
||
.back-section { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.form { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 2.4rem; | ||
} | ||
|
||
.amount-input { | ||
display: flex; | ||
|
||
@include mobile-cashier-v2 { | ||
flex-direction: column; | ||
gap: 1.6rem; | ||
} | ||
} |
94 changes: 94 additions & 0 deletions
94
...awal/components/PaymentAgentUnlistedWithdrawalForm/PaymentAgentUnlistedWithdrawalForm.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,94 @@ | ||
import React from 'react'; | ||
import { Field, FieldProps, Form, Formik } from 'formik'; | ||
import { useActiveAccount } from '@deriv/api-v2'; | ||
import { LabelPairedCircleXmarkMdFillIcon, StandaloneArrowLeftBoldIcon } from '@deriv/quill-icons'; | ||
import { Button, Input, Text } from '@deriv-com/ui'; | ||
import styles from './PaymentAgentUnlistedWithdrawalForm.module.scss'; | ||
|
||
const PaymentAgentUnlistedWithdrawalForm = () => { | ||
const { data: activeAccount } = useActiveAccount(); | ||
const onSubmitHandler = () => undefined; | ||
|
||
return ( | ||
<div className={styles.container}> | ||
<div className={styles['back-section']}> | ||
<StandaloneArrowLeftBoldIcon data-testid='dt-back-arrow-icon' iconSize='md' /> | ||
<Text size='sm' weight='bold'> | ||
Back to list | ||
</Text> | ||
</div> | ||
<Formik | ||
initialValues={{ | ||
accountNumber: '', | ||
amount: '', | ||
}} | ||
onSubmit={onSubmitHandler} | ||
> | ||
{({ errors, isSubmitting, isValid, setFieldValue, touched, values }) => { | ||
const isFormEmpty = !Object.values(values).some(Boolean); | ||
|
||
return ( | ||
<Form className={styles.form}> | ||
<Field name='account_number'> | ||
{({ field }: FieldProps) => ( | ||
<Input | ||
{...field} | ||
autoComplete='off' | ||
error={touched.accountNumber && Boolean(errors.accountNumber)} | ||
isFullWidth | ||
label='Enter the payment agent account number' | ||
maxLength={30} | ||
message='Example: CR123456789' | ||
required | ||
rightPlaceholder={ | ||
errors.accountNumber ? ( | ||
<LabelPairedCircleXmarkMdFillIcon | ||
onClick={() => setFieldValue('accountNumber', '')} | ||
/> | ||
) : null | ||
} | ||
type='text' | ||
/> | ||
)} | ||
</Field> | ||
<div className={styles['amount-input']}> | ||
<Field name='amount'> | ||
{({ field }: FieldProps) => ( | ||
<Input | ||
{...field} | ||
autoComplete='off' | ||
error={touched.amount && Boolean(errors.amount)} | ||
isFullWidth | ||
label='Enter amount' | ||
maxLength={30} | ||
required | ||
rightPlaceholder={ | ||
<Text as='span' size='sm'> | ||
{activeAccount?.currency_config?.display_code} | ||
</Text> | ||
} | ||
type='text' | ||
/> | ||
)} | ||
</Field> | ||
<Button | ||
disabled={!isValid || isSubmitting || isFormEmpty} | ||
size='lg' | ||
textSize='sm' | ||
type='submit' | ||
> | ||
Continue | ||
</Button> | ||
</div> | ||
</Form> | ||
); | ||
}} | ||
</Formik> | ||
<Text as='p' color='less-prominent' size='xs'> | ||
Note: Deriv does not charge any transfer fees. | ||
</Text> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PaymentAgentUnlistedWithdrawalForm; |
1 change: 1 addition & 0 deletions
1
...ntAgent/lib/PaymentAgentWithdrawal/components/PaymentAgentUnlistedWithdrawalForm/index.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 @@ | ||
export { default as PaymentAgentUnlistedWithdrawalForm } from './PaymentAgentUnlistedWithdrawalForm'; |
13 changes: 13 additions & 0 deletions
13
...entAgentWithdrawalReceipt/PaymentAgentReceiptDetail/PaymentAgentReceiptDetail.module.scss
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,13 @@ | ||
.container { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.4rem; | ||
flex-basis: 0; | ||
} | ||
|
||
.icon-wrapper { | ||
display: flex; | ||
align-items: center; | ||
width: 1.6rem; | ||
height: 1.6rem; | ||
} |
Oops, something went wrong.