Skip to content

Commit

Permalink
feat(frictions): fix empty response
Browse files Browse the repository at this point in the history
  • Loading branch information
mperdomo-bc committed Jan 17, 2024
1 parent 5017053 commit 530b0c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export interface IdentityVerificationState {
userAddresses: RemoteDataType<string, FindAddressResponse>
userRetrieveAddress: RemoteDataType<string, RetrieveAddress>
verificationStep: StepsType | null
verificationSteps: RemoteDataType<string, VerificationStepsType>
verificationSteps: RemoteDataType<string, VerificationStepsType | ''>
}

export type InfoAndResidentialFormValuesType = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ const CompleteProfile = (props) => {
dispatch(custodial.fetchProductEligibilityForUser())
}, [])

if (handholdData === '') {
dispatch(modals.closeModal(ModalName.COMPLETE_USER_PROFILE))
return null
}

const itemsLength = handholdData?.items?.length ?? 0
const completedSteps =
handholdData?.items?.filter((step) => step.status === 'COMPLETED').length ?? 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ const CompleteYourProfile = () => {
dispatch(buySell.fetchAccumulatedTrades({ product: ProductTypes.SIMPLEBUY }))
}, [])

const itemsLength = verificationSteps?.items?.length ?? 0
const completedSteps =
verificationSteps?.items?.filter((step) => step.status === 'COMPLETED').length ?? 0

const percentage = itemsLength ? (completedSteps / itemsLength) * 100 : 0

const handleClick = useCallback(() => {
dispatch(
modals.showModal(ModalName.COMPLETE_USER_PROFILE, {
Expand All @@ -60,6 +54,14 @@ const CompleteYourProfile = () => {
dispatch(cache.announcementDismissed(ANNOUNCEMENTS.COMPLETE_PROFILE))
}

if (verificationSteps === '') return null

const itemsLength = verificationSteps?.items?.length ?? 0
const completedSteps =
verificationSteps?.items?.filter((step) => step.status === 'COMPLETED').length ?? 0

const percentage = itemsLength ? (completedSteps / itemsLength) * 100 : 0

return (
<Wrapper>
<Row>
Expand Down

0 comments on commit 530b0c2

Please sign in to comment.