[TASK-7285] fix(cashout): format bank account number#552
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
WalkthroughThe pull request introduces modifications to the Changes
Possibly related PRs
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
src/components/Cashout/Components/Initial.view.tsx (3)
Line range hint
214-220: Consider adding validation for sanitized bank accountWhile the sanitization is good, consider validating the sanitized identifier before setting it as valid.
const handleBankAccountSelect = (accountIdentifier: string) => { if (!xchainAllowed) return const sanitizedIdentifier = sanitizeBankAccount(accountIdentifier) + const isValid = validateBankAccount(sanitizedIdentifier) setBankAccountNumber(sanitizedIdentifier) - setIsValidBankAccountNumber(true) + setIsValidBankAccountNumber(isValid) setIsValidatingBankAccountNumber(false) }
Line range hint
222-234: Extract magic number for US routing number lengthConsider extracting the magic number 9 into a named constant for better maintainability.
+const US_ROUTING_NUMBER_LENGTH = 9; + const matchAccount = (storedAccount: any, inputAccount: string) => { const sanitizedInput = sanitizeBankAccount(inputAccount) const sanitizedStored = sanitizeBankAccount(storedAccount.account_identifier) if (storedAccount.account_type === 'iban') { return sanitizedInput === sanitizedStored } else if (storedAccount.account_type === 'us') { // For US accounts, only match against the account number part (after routing number) - const storedAccountNumber = sanitizedStored.slice(9) + const storedAccountNumber = sanitizedStored.slice(US_ROUTING_NUMBER_LENGTH) return sanitizedInput === storedAccountNumber } return false }
Line range hint
367-389: Remove manual error state managementBased on previous feedback, the
ValidatedInputcomponent will handle error messages for invalid bank accounts. Manual error state management is unnecessary and should be removed.<ValidatedInput placeholder="IBAN / US account number" label="To" value={bankAccountNumber} className="uppercase" debounceTime={750} validate={validateBankAccount} onUpdate={({ value, isValid, isChanging }) => { setBankAccountNumber(value.toLowerCase()) setIsValidBankAccountNumber(isValid) setIsValidatingBankAccountNumber(isChanging) - if (!isChanging && value && !isValid) { - setErrorState({ - showError: true, - errorMessage: - 'Invalid bank account. For US bank accounts, enter your routing number and account number separately.', - }) - } else { - setErrorState({ - showError: false, - errorMessage: '', - }) - } }} autoComplete="on" name="bank-account" formatDisplayValue={formatBankAccountDisplay} />
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/components/Cashout/Components/Initial.view.tsx(1 hunks)
🧰 Additional context used
📓 Learnings (1)
src/components/Cashout/Components/Initial.view.tsx (1)
Learnt from: jjramirezn
PR: peanutprotocol/peanut-ui#484
File: src/components/Cashout/Components/Initial.view.tsx:273-274
Timestamp: 2024-11-12T09:39:20.720Z
Learning: In the `InitialCashoutView` component (`src/components/Cashout/Components/Initial.view.tsx`), linked bank accounts should not generate error states, and the `ValidatedInput` component will clear any error messages if needed. Therefore, it's unnecessary to manually clear the error state when selecting or clearing linked bank accounts.
🔇 Additional comments (1)
src/components/Cashout/Components/Initial.view.tsx (1)
23-23: LGTM: Import changes align with PR objective
The new utility imports for bank account formatting are appropriate and well-named.
3adb383 to
b6aec7b
Compare
Summary by CodeRabbit
New Features
Bug Fixes
Improvements