diff --git a/src/apps/review/src/lib/utils/reviewPhaseGuards.ts b/src/apps/review/src/lib/utils/reviewPhaseGuards.ts index 35cac9821..0d7ccb7f8 100644 --- a/src/apps/review/src/lib/utils/reviewPhaseGuards.ts +++ b/src/apps/review/src/lib/utils/reviewPhaseGuards.ts @@ -180,11 +180,28 @@ export const shouldIncludeInReviewPhase = ( } const normalizedCandidateList = Array.from(normalizedCandidates) - const isExcluded = normalizedCandidateList - .some(candidate => ( - EXCLUDED_REVIEW_TYPE_FRAGMENTS - .some(fragment => candidate.includes(fragment)) - )) + + const hasExplicitReviewPhase = hasReviewPhase(submission.review, phases) + || ( + Array.isArray(submission.reviews) + && submission.reviews.some(review => hasReviewPhase(review, phases)) + ) + + const isExcluded = normalizedCandidateList.some(candidate => ( + EXCLUDED_REVIEW_TYPE_FRAGMENTS.some(fragment => { + if (!candidate.includes(fragment)) { + return false + } + + if (fragment === 'iterative' && hasExplicitReviewPhase) { + // Treat records that are tied to the official Review phase as review entries, + // even when the review type string mentions "Iterative". + return false + } + + return true + }) + )) if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console diff --git a/src/apps/wallet/src/home/tabs/home/HomeTab.tsx b/src/apps/wallet/src/home/tabs/home/HomeTab.tsx index 78619a12f..1ed734c1c 100644 --- a/src/apps/wallet/src/home/tabs/home/HomeTab.tsx +++ b/src/apps/wallet/src/home/tabs/home/HomeTab.tsx @@ -1,10 +1,9 @@ /* eslint-disable react/jsx-wrap-multilines */ -import { FC, useEffect, useState } from 'react' +import { FC, useMemo } from 'react' import { UserProfile } from '~/libs/core' import { IconOutline, LinkButton, LoadingCircles } from '~/libs/ui' -import { Balance } from '../../../lib/models/WalletDetails' import { InfoRow, PayoutGuard } from '../../../lib' import { BannerImage, BannerText } from '../../../lib/assets/home' import { nullToZero } from '../../../lib/util' @@ -17,21 +16,136 @@ interface HomeTabProps { profile: UserProfile } +type WalletDetailsData = NonNullable +interface WalletInfoRowsProps { + walletDetails: WalletDetailsData + profile: UserProfile + balanceSum: number +} + +const WalletInfoRows: FC = props => ( +
+ + } + /> + + + {props.walletDetails.withdrawalMethod.isSetupComplete && ( + + } + /> + )} + {props.walletDetails.taxForm.isSetupComplete && ( + + } + /> + )} + + {!props.walletDetails.withdrawalMethod.isSetupComplete && ( + } + action={ + + } + /> + )} + + {!props.walletDetails.taxForm.isSetupComplete && ( + } + action={ + + } + /> + )} + {!props.walletDetails.identityVerification.isSetupComplete && ( + } + action={ + + } + /> + )} + +
+) + const HomeTab: FC = props => { const { data: walletDetails, isLoading, error }: WalletDetailsResponse = useWalletDetails() - const [balanceSum, setBalanceSum] = useState(0) - useEffect(() => { - if (walletDetails) { - setBalanceSum( - walletDetails.account.balances.reduce((sum: number, balance: Balance) => sum + balance.amount, 0), - ) - } - }, [walletDetails]) + const balanceSum = useMemo( + () => (walletDetails ? walletDetails.account.balances.reduce((sum, balance) => sum + balance.amount, 0) : 0), + [walletDetails], + ) if (error) { - return
{error}
+ let errorMessage = 'Unable to load wallet details.' + + if (typeof error === 'string') { + errorMessage = error + } else if (error && typeof error === 'object' && 'message' in error) { + errorMessage = (error as Error).message || errorMessage + } + + return
{errorMessage}
} return ( @@ -42,117 +156,7 @@ const HomeTab: FC = props => { {isLoading && } {!isLoading && walletDetails && ( -
- - } - /> - - - {walletDetails.withdrawalMethod.isSetupComplete && ( - - } - /> - )} - {walletDetails.taxForm.isSetupComplete && ( - - } - /> - )} - - {!walletDetails?.withdrawalMethod.isSetupComplete && ( - - ) - } - action={ - - } - /> - )} - - {!walletDetails?.taxForm.isSetupComplete && ( - - } - action={ - - } - /> - )} - {!walletDetails?.identityVerification.isSetupComplete && ( - } - action={ - - } - /> - )} - -
+ )} ) diff --git a/src/apps/wallet/src/lib/hooks/use-wallet-details.ts b/src/apps/wallet/src/lib/hooks/use-wallet-details.ts index d6dbfde92..fc30a228a 100644 --- a/src/apps/wallet/src/lib/hooks/use-wallet-details.ts +++ b/src/apps/wallet/src/lib/hooks/use-wallet-details.ts @@ -5,7 +5,7 @@ import { getWalletDetails } from '../services/wallet' export interface Response { data?: Readonly - error?: Readonly + error?: Readonly | string mutate: KeyedMutator isLoading?: Readonly }