Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/components/Cashout/Components/Initial.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const InitialCashoutView = ({
}),
})

if (userIdResponse.status === 404) {
if (userIdResponse.status === 404 || userIdResponse.status === 400) {
setUserType('NEW')
} else {
const response = await userIdResponse.json()
Expand Down Expand Up @@ -164,8 +164,8 @@ export const InitialCashoutView = ({
if (user?.user.kycStatus == 'verified') {
const account = user.accounts.find(
(account: any) =>
account.account_identifier.toLowerCase() ===
recipientBankAccount.replaceAll(' ', '').toLowerCase()
account.account_identifier.replaceAll(/\s/g, '').toLowerCase() ===
recipientBankAccount.replaceAll(/\s/g, '').toLowerCase()
)

if (account) {
Expand Down Expand Up @@ -330,7 +330,9 @@ export const InitialCashoutView = ({
className="flex w-full flex-col items-start justify-center gap-2 overflow-hidden"
>
<label className="text-left text-h8 font-light">
Cashout to a new bank account:
{user && user.accounts.length > 0
? 'Cash out to a new bank account:'
: 'Cash out to a bank account:'}
</label>
<div
className={twMerge(
Expand Down Expand Up @@ -361,7 +363,7 @@ export const InitialCashoutView = ({
</>
) : (
<div className="flex w-full flex-col items-start justify-center gap-2">
<label className="text-left text-h8 font-light">Cashout to a new bank account:</label>
<label className="text-left text-h8 font-light">Cash out to a bank account:</label>
<div
className={twMerge(
'flex w-full border border-black p-2',
Expand Down
16 changes: 10 additions & 6 deletions src/components/Claim/Link/Initial.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,29 +180,33 @@ export const InitialClaimLinkView = ({
setLoadingState('Getting KYC status')

if (!user) {
console.log(`user not logged in, getting account status for ${recipient.address}`)
const userIdResponse = await fetch('/api/peanut/user/get-user-id', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
accountIdentifier: recipient.name,
accountIdentifier: recipient.address,
}),
})

const response = await userIdResponse.json()
if (response.isNewUser || (response.error && response.error == 'User not found for given IBAN')) {
console.log('response', response)
if (response.isNewUser || (response.error && response.error === 'User not found for given IBAN')) {
setUserType('NEW')
console.log('New user!')
} else {
// TODO: if not logged in but existing user, should show this somewhere in the UI.
setUserType('EXISTING')
console.log('Existing user!')
}
setOfframpForm({
name: '',
email: '',
password: '',
recipient: recipient.name ?? '',
})
setInitialKYCStep(0)
setInitialKYCStep(0) // even if user exists, need to login
} else {
setOfframpForm({
email: user?.user?.email ?? '',
Expand All @@ -213,8 +217,8 @@ export const InitialClaimLinkView = ({
if (user?.user.kycStatus === 'verified') {
const account = user.accounts.find(
(account: any) =>
account.account_identifier.toLowerCase() ===
recipient.name?.replaceAll(' ', '').toLowerCase()
account.account_identifier.replaceAll(/\s/g, '').toLowerCase() ===
recipient.name?.replaceAll(/\s/g, '').toLowerCase()
)

if (account) {
Expand Down
4 changes: 1 addition & 3 deletions src/components/Global/LinkAccountComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,8 @@ export const GlobaLinkAccountComponent = ({ accountNumber, onCompleted }: IGloba
const sanitizedAccountNumber = accountNumber.replaceAll(/\s/g, '').toLowerCase()

if (isIBAN(sanitizedAccountNumber)) {
console.log(`Set bank account type to iban for ${sanitizedAccountNumber}`)
setAccountDetailsValue('type', 'iban')
} else if (/^[0-9]{6,17}$/.test(sanitizedAccountNumber)) {
console.log(`Set bank account type to us for ${sanitizedAccountNumber}`)
setAccountDetailsValue('type', 'us')
} else {
setIbanFormError('accountNumber', { message: 'Invalid account number' })
Expand Down Expand Up @@ -204,7 +202,7 @@ export const GlobaLinkAccountComponent = ({ accountNumber, onCompleted }: IGloba
customerId,
data.id,
accountType,
getIbanFormValue('accountNumber')?.replaceAll(' ', '') ?? '',
getIbanFormValue('accountNumber')?.replaceAll(/\s/g, '') ?? '',
address
)
await fetchUser()
Expand Down