From a8ebd8604eb619bcb3898b2765e9fcbbce1363d5 Mon Sep 17 00:00:00 2001 From: JJ Adonis Date: Mon, 22 Nov 2021 08:56:20 +0800 Subject: [PATCH] `loan` - translations and minor ui updates (#1372) * UI updates * snapshot --- .../Loans/VaultDetail/VaultDetailScreen.tsx | 2 +- .../screens/Loans/components/Vaults.tsx | 5 +- .../Loans/screens/CreateVaultScreen.tsx | 6 +- .../Loans/screens/EditCollateralScreen.tsx | 2 +- .../Loans/screens/PaybackLoanScreen.tsx | 2 +- .../screens/CreateWallet/LoansFaq.tsx | 4 +- .../__snapshots__/LoansFaq.test.tsx.snap | 4 +- shared/translations/languages/de.json | 111 ++++++++++-------- website/src/pages/api/v0/settings/flags.ts | 4 +- 9 files changed, 78 insertions(+), 62 deletions(-) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/VaultDetail/VaultDetailScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/VaultDetail/VaultDetailScreen.tsx index 3a5095d7a9..868bbc83c1 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/VaultDetail/VaultDetailScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/VaultDetail/VaultDetailScreen.tsx @@ -177,7 +177,7 @@ function VaultInfoSection (props: { vault?: LoanVault }): JSX.Element | null { <> state.loans.vaults) useEffect(() => { - dispatch(fetchVaults({ address, client })) + dispatch(fetchVaults({ + address, + client + })) }, [blockCount]) useEffect(() => { diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx index e5db05cf30..3ee2469c0a 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/CreateVaultScreen.tsx @@ -27,6 +27,7 @@ import { DFITokenSelector, DFIUtxoSelector } from '@store/wallet' import { ConversionInfoText } from '@components/ConversionInfoText' import { InfoTextLink } from '@components/InfoTextLink' import { queueConvertTransaction } from '@hooks/wallet/Conversion' +import { createSelector } from '@reduxjs/toolkit' type Props = StackScreenProps @@ -36,7 +37,10 @@ export function CreateVaultScreen ({ }: Props): JSX.Element { const dispatch = useDispatch() const client = useWhaleApiClient() - const loanSchemes: LoanScheme[] = useSelector((state: RootState) => state.loans.loanSchemes) + const loanSchemesSelector = createSelector((state: RootState) => state.loans.loanSchemes, + (schemes) => schemes.map((c) => c).sort((a, b) => new BigNumber(a.minColRatio).minus(b.minColRatio).toNumber())) + const loanSchemes = useSelector((state: RootState) => loanSchemesSelector(state)) + const logger = useLogger() const [fee, setFee] = useState(new BigNumber(0.0001)) const [selectedLoanScheme, setSelectedLoanScheme] = useState(route.params?.loanScheme) diff --git a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx index 9fd30c33ea..d9d1d92824 100644 --- a/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx +++ b/mobile-app/app/screens/AppNavigator/screens/Loans/screens/EditCollateralScreen.tsx @@ -370,7 +370,7 @@ function VaultIdSection (props: { vault: LoanVaultActive }): JSX.Element { testID='text_total_collateral_value' value={new BigNumber(vault.loanScheme.minColRatio ?? 0).toFixed(2)} suffix='%' suffixType='text' - lhs={translate('screens/EditCollateralScreen', 'Min. collateralization ratio')} + lhs={translate('screens/EditCollateralScreen', 'Min. collateral ratio')} /> - {translate('screens/PaybackLoanScreen', 'Min. collateralization ratio')} + {translate('screens/PaybackLoanScreen', 'Min. collateral ratio')} - {translate('components/LoansFaq', 'The decentralized loan feature allows you to borrow decentralized tokens by using your cryptocurrency holdings as collateral. To start, you must first create a vault and deposit collaterals before you can take a loan.')} + {translate('components/LoansFaq', 'The decentralized loan feature allows you to borrow decentralised tokens by using your cryptocurrency holdings as collateral. To start, you must first create a vault and deposit collaterals before you can take a loan.')} - The decentralized loan feature allows you to borrow decentralized tokens by using your cryptocurrency holdings as collateral. To start, you must first create a vault and deposit collaterals before you can take a loan. + The decentralized loan feature allows you to borrow decentralised tokens by using your cryptocurrency holdings as collateral. To start, you must first create a vault and deposit collaterals before you can take a loan. - Liquidated: When a vault’s collateralization ratio falls below the minimum requirement + Liquidated: When a vault's collateralization ratio falls below the minimum requirement =0.15.2', + version: '>=0.15.3', description: 'Browse loan tokens provided by DeFiChain', networks: [EnvironmentNetwork.RemotePlayground, EnvironmentNetwork.LocalPlayground], platforms: ['ios', 'android', 'web'] @@ -22,7 +22,7 @@ export default async function handle (req: NextApiRequest, res: NextApiResponse< id: 'loan', name: 'Loans', stage: 'beta', - version: '>=0.15.2', + version: '>=0.15.3', description: 'Browse loan tokens provided by DeFiChain', networks: [EnvironmentNetwork.MainNet, EnvironmentNetwork.TestNet], platforms: ['ios', 'android', 'web']