-
Notifications
You must be signed in to change notification settings - Fork 510
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(frictions): restructure frictions code (#6243)
- Loading branch information
1 parent
662a6bb
commit 10da9da
Showing
15 changed files
with
63 additions
and
260 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
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
40 changes: 10 additions & 30 deletions
40
packages/blockchain-wallet-v4-frontend/src/modals/Onboarding/CompleteProfile/selectors.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,50 +1,30 @@ | ||
import { BSPaymentMethodsType, BSPaymentTypes, TermType } from '@core/types' | ||
import { BSPaymentMethodsType, BSPaymentTypes } from '@core/types' | ||
import { model, selectors } from 'data' | ||
import { RootState } from 'data/rootReducer' | ||
|
||
const { KYC_STATES } = model.profile | ||
|
||
type ReturnData = { | ||
isBankOrCardLinked: boolean | ||
isBuyCrypto: boolean | ||
isKycPending: boolean | ||
isVerifiedId: boolean | ||
isKycVerified: boolean | ||
} | ||
|
||
export const getData = (state: RootState): ReturnData => { | ||
const userData = selectors.modules.profile.getUserData(state).getOrElse({ | ||
kycState: undefined, | ||
tiers: { current: 0 } | ||
}) | ||
|
||
const isKycPending = [KYC_STATES.PENDING, KYC_STATES.UNDER_REVIEW].includes(userData.kycState) | ||
|
||
const userData = selectors.modules.profile.getUserData(state).getOrElse({ kycState: undefined }) | ||
const isKycVerified = userData.kycState === KYC_STATES.VERIFIED | ||
|
||
// user have some cards or banks linked | ||
const cards = selectors.components.buySell.getBSCards(state).getOrElse([]) | ||
// Check if user has cards or banks linked | ||
const hasLinkedCards = selectors.components.buySell.getBSCards(state).getOrElse([]).length > 0 | ||
const paymentMethods = selectors.components.buySell | ||
.getBSPaymentMethods(state) | ||
.getOrElse({} as BSPaymentMethodsType) | ||
const isAnyBankLinked = | ||
paymentMethods?.methods?.length > 0 && | ||
paymentMethods.methods.find( | ||
(method) => method.eligible && method.type === BSPaymentTypes.LINK_BANK | ||
) | ||
const isBankOrCardLinked = !!(cards.length > 0 || isAnyBankLinked) | ||
|
||
// user accumulated amount all the time | ||
const accumulatedTrades = selectors.components.buySell.getAccumulatedTrades(state).getOrElse([]) | ||
|
||
const isBuyCrypto = | ||
Number( | ||
accumulatedTrades?.find((accumulated) => accumulated.termType === TermType.ALL)?.amount?.value | ||
) > 0 ?? false | ||
const hasLinkedBank = paymentMethods?.methods?.some( | ||
(method) => method.eligible && method.type === BSPaymentTypes.LINK_BANK | ||
) | ||
const isBankOrCardLinked = hasLinkedCards || hasLinkedBank | ||
|
||
return { | ||
isBankOrCardLinked, | ||
isBuyCrypto, | ||
isKycPending, | ||
isVerifiedId: isKycVerified | ||
isKycVerified | ||
} | ||
} |
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
4 changes: 2 additions & 2 deletions
4
...ages/blockchain-wallet-v4-frontend/src/modals/Onboarding/FinProms/SelfAssessment/types.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
Oops, something went wrong.