Skip to content

Commit

Permalink
Merge branch 'main' into l10n/main
Browse files Browse the repository at this point in the history
  • Loading branch information
valora-bot authored Jan 5, 2025
2 parents d0e8a14 + fc83679 commit 37e1bf2
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/earn/EarnEnterAmount.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ describe('EarnEnterAmount', () => {
prepareTransactionError: undefined,
isPreparingTransactions: false,
})
const { getByTestId, getByText } = render(
const { getByTestId, getByText, queryByTestId } = render(
<Provider store={store}>
<MockedNavigator component={EarnEnterAmount} params={swapDepositParams} />
</Provider>
Expand All @@ -524,6 +524,8 @@ describe('EarnEnterAmount', () => {
expect(getByTestId('EarnEnterAmount/Fees')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Fees')).toHaveTextContent('₱0.012')

expect(queryByTestId('EarnEnterAmount/Duration')).toBeFalsy()

fireEvent.press(getByText('earnFlow.enterAmount.continue'))

await waitFor(() => expect(AppAnalytics.track).toHaveBeenCalledTimes(1))
Expand Down Expand Up @@ -588,6 +590,9 @@ describe('EarnEnterAmount', () => {
expect(getByTestId('EarnEnterAmount/Fees')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Fees')).toHaveTextContent('₱0.012')

expect(getByTestId('EarnEnterAmount/Duration')).toBeTruthy()
expect(getByTestId('EarnEnterAmount/Duration')).toHaveTextContent('{"minutes":5}')

fireEvent.press(getByText('earnFlow.enterAmount.continue'))

await waitFor(() => expect(AppAnalytics.track).toHaveBeenCalledTimes(2)) // one for token selection, one for continue press
Expand Down
56 changes: 56 additions & 0 deletions src/earn/EarnEnterAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export default function EarnEnterAmount({ route }: Props) {
const reviewBottomSheetRef = useRef<BottomSheetModalRefType>(null)
const feeDetailsBottomSheetRef = useRef<BottomSheetModalRefType>(null)
const swapDetailsBottomSheetRef = useRef<BottomSheetModalRefType>(null)
const estimatedDurationBottomSheetRef = useRef<BottomSheetModalRefType>(null)

const [selectedPercentage, setSelectedPercentage] = useState<number | null>(null)
const hooksApiUrl = useSelector(hooksApiUrlSelector)
Expand Down Expand Up @@ -391,6 +392,7 @@ export default function EarnEnterAmount({ route }: Props) {
prepareTransactionsResult={prepareTransactionsResult}
feeDetailsBottomSheetRef={feeDetailsBottomSheetRef}
swapDetailsBottomSheetRef={swapDetailsBottomSheetRef}
estimatedDurationBottomSheetRef={estimatedDurationBottomSheetRef}
swapTransaction={swapTransaction}
/>
)}
Expand Down Expand Up @@ -511,6 +513,9 @@ export default function EarnEnterAmount({ route }: Props) {
parsedTokenAmount={processedAmounts.token.bignum}
/>
)}
{swapTransaction?.swapType === 'cross-chain' && processedAmounts.token.bignum && (
<EstimatedDurationBottomSheet forwardedRef={estimatedDurationBottomSheetRef} />
)}
{processedAmounts.token.bignum && prepareTransactionsResult?.type === 'possible' && (
<EarnDepositBottomSheet
forwardedRef={reviewBottomSheetRef}
Expand Down Expand Up @@ -621,6 +626,7 @@ function TransactionDepositDetails({
swapTransaction,
feeDetailsBottomSheetRef,
swapDetailsBottomSheetRef,
estimatedDurationBottomSheetRef,
}: {
pool: EarnPosition
token: TokenBalance
Expand All @@ -629,9 +635,12 @@ function TransactionDepositDetails({
swapTransaction?: SwapTransaction
feeDetailsBottomSheetRef: React.RefObject<BottomSheetModalRefType>
swapDetailsBottomSheetRef: React.RefObject<BottomSheetModalRefType>
estimatedDurationBottomSheetRef: React.RefObject<BottomSheetModalRefType>
}) {
const { t } = useTranslation()
const { maxFeeAmount, feeCurrency } = getFeeCurrencyAndAmounts(prepareTransactionsResult)
const estimatedDurationInSeconds =
swapTransaction?.swapType === 'cross-chain' ? swapTransaction.estimatedDuration : undefined

const depositAmount = useMemo(
() =>
Expand Down Expand Up @@ -713,6 +722,24 @@ function TransactionDepositDetails({
/>
</View>
</View>
{!!estimatedDurationInSeconds && (
<View style={styles.txDetailsLineItem}>
<LabelWithInfo
label={t('earnFlow.enterAmount.estimatedDuration')}
onPress={() => {
estimatedDurationBottomSheetRef?.current?.snapToIndex(0)
}}
testID="LabelWithInfo/DurationLabel"
/>
<View style={styles.txDetailsValue}>
<Text style={styles.txDetailsValueText} testID="EarnEnterAmount/Duration">
{t('swapScreen.transactionDetails.estimatedTransactionTimeInMinutes', {
minutes: Math.ceil(estimatedDurationInSeconds / 60),
})}
</Text>
</View>
</View>
)}
</View>
)
)
Expand Down Expand Up @@ -952,6 +979,32 @@ function SwapDetailsBottomSheet({
)
}

function EstimatedDurationBottomSheet({
forwardedRef,
}: {
forwardedRef: React.RefObject<BottomSheetModalRefType>
}) {
const { t } = useTranslation()
return (
<BottomSheet
forwardedRef={forwardedRef}
title={t('swapScreen.transactionDetails.estimatedTransactionTime')}
description={t('swapScreen.transactionDetails.estimatedTransactionTimeInfo')}
testId="EstimatedDurationBottomSheet"
>
<Button
type={BtnTypes.SECONDARY}
size={BtnSizes.FULL}
onPress={() => {
forwardedRef.current?.close()
}}
text={t('swapScreen.transactionDetails.infoDismissButton')}
style={styles.bottomSheetButton}
/>
</BottomSheet>
)
}

const styles = StyleSheet.create({
safeAreaContainer: {
flex: 1,
Expand Down Expand Up @@ -1042,4 +1095,7 @@ const styles = StyleSheet.create({
...typeScale.bodySmall,
color: Colors.black,
},
bottomSheetButton: {
marginTop: Spacing.Thick24,
},
})

0 comments on commit 37e1bf2

Please sign in to comment.