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.
[WALL] aum / WALL-4049/ wallet-crypto-withdrawal-age-verification-err…
…or (deriv-com#15278) * feat: added CryptoLimitAgeVerified error screen for WithdrawalCrypto * fix: fix TS error * feat: added countLimitMessageFn to handle daily count transfer limit * feat: added daily count message for demo wallets
- Loading branch information
Showing
6 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
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
68 changes: 68 additions & 0 deletions
68
...features/cashier/modules/Transfer/hooks/useTransferMessages/utils/countLimitsMessageFn.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,68 @@ | ||
import { TMessageFnProps, TTransferMessage } from '../../../types'; | ||
|
||
let text: TTransferMessage['message']['text'], | ||
type: TTransferMessage['type'], | ||
values: TTransferMessage['message']['values']; | ||
|
||
const countLimitMessageFn = ({ activeWallet, limits, sourceAccount, targetAccount }: TMessageFnProps) => { | ||
if (!targetAccount) return null; | ||
|
||
const isTransferBetweenWallets = | ||
sourceAccount.account_category === 'wallet' && targetAccount.account_category === 'wallet'; | ||
|
||
const isDemoTransfer = activeWallet?.is_virtual; | ||
|
||
const keyAccountType = | ||
[sourceAccount, targetAccount].find(acc => acc.account_category !== 'wallet')?.account_type ?? 'internal'; | ||
|
||
const platformKey = keyAccountType === 'standard' ? 'dtrade' : keyAccountType; | ||
|
||
const allowedCount = isDemoTransfer | ||
? //@ts-expect-error needs backend type | ||
(limits?.daily_transfers?.virtual?.allowed as number) | ||
: //@ts-expect-error needs backend type | ||
(limits?.daily_transfers?.[platformKey]?.allowed as number); | ||
|
||
const availableCount = isDemoTransfer | ||
? //@ts-expect-error needs backend type | ||
(limits?.daily_transfers?.virtual?.available as number) | ||
: //@ts-expect-error needs backend type | ||
(limits?.daily_transfers?.[platformKey]?.available as number); | ||
|
||
if (allowedCount === undefined || availableCount === undefined) return null; | ||
|
||
if (availableCount === 0 && isDemoTransfer) { | ||
text = | ||
'You have reached your daily transfer limit of {{allowedCount}} transfers for your virtual funds. The limit will reset at 00:00 GMT.'; | ||
values = { | ||
allowedCount, | ||
}; | ||
type = 'error' as const; | ||
|
||
return { | ||
message: { text, values }, | ||
type, | ||
}; | ||
} | ||
|
||
if (availableCount === 0) { | ||
text = isTransferBetweenWallets | ||
? 'You have reached your daily transfer limit of {{allowedCount}} transfers between your Wallets. The limit will reset at 00:00 GMT.' | ||
: 'You have reached your daily transfer limit of {{allowedCount}} transfers between your {{sourceAccountName}} and {{targetAccountName}}. The limit will reset at 00:00 GMT.'; | ||
values = { | ||
allowedCount, | ||
sourceAccountName: sourceAccount.accountName, | ||
targetAccountName: targetAccount.accountName, | ||
}; | ||
type = 'error' as const; | ||
|
||
return { | ||
message: { text, values }, | ||
type, | ||
}; | ||
} | ||
|
||
return null; | ||
}; | ||
|
||
export default countLimitMessageFn; |
2 changes: 2 additions & 0 deletions
2
...es/wallets/src/features/cashier/modules/Transfer/hooks/useTransferMessages/utils/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
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