Skip to content

Commit

Permalink
flow fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vsubhuman committed Nov 21, 2023
1 parent a090101 commit 491ce02
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
9 changes: 3 additions & 6 deletions packages/yoroi-extension/app/components/swap/PriceInput.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// @flow
import type { Node } from 'react';
import { Box, Typography } from '@mui/material';

type AssetAmount = {|
ticker: string,
amount: number,
|};
import type { AssetAmount } from './types'
import { BigNumber } from 'bignumber.js';

type Props = {|
label: string,
Expand Down Expand Up @@ -64,7 +61,7 @@ export default function PriceInput({
placeholder="0"
bgcolor={readonly ? 'grayscale.50' : 'common.white'}
readOnly={readonly}
value={baseCurrency.amount / quoteCurrency.amount || 0}
value={(new BigNumber(baseCurrency.amount)).div(quoteCurrency.amount).toString()}
/>
<Box sx={{ justifySelf: 'end' }}>
<Box height="100%" width="min-content" display="flex" alignItems="center">
Expand Down
7 changes: 1 addition & 6 deletions packages/yoroi-extension/app/components/swap/SwapInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@ import { useState } from 'react';
import { Box, Typography } from '@mui/material';
import { ReactComponent as ChevronDownIcon } from '../../assets/images/revamp/icons/chevron-down.inline.svg';
import { ReactComponent as DefaultTokenImage } from '../../assets/images/revamp/token-default.inline.svg';

type AssetAmount = {|
ticker: string,
amount: number,
walletAmount: number,
|};
import type { AssetAmount } from './types';

type Props = {|
label: string,
Expand Down
7 changes: 7 additions & 0 deletions packages/yoroi-extension/app/components/swap/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@flow

export type AssetAmount = {|
ticker: string,
amount: string,
walletAmount: number,
|};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// @flow
import type { Node } from 'react';
import { useState } from 'react';
import { Box, Button, Typography } from '@mui/material';
import { ReactComponent as SwitchIcon } from '../../../assets/images/revamp/icons/switch.inline.svg';
Expand All @@ -8,18 +9,22 @@ import { ReactComponent as UsdaTokenImage } from './usda.inline.svg';
import SwapInput from '../../../components/swap/SwapInput';
import PriceInput from '../../../components/swap/PriceInput';

const defaultFromAsset = { amount: '', walletAmount: 212, ticker: 'TADA' };
const defaultToAsset = { amount: '', walletAmount: 0, ticker: '' };
const defaultFromAsset = {
amount: '',
ticker: 'TADA',
walletAmount: 212,
};
const defaultToAsset = {
amount: '',
ticker: '',
walletAmount: 0,
};

export default function SwapForm() {
export default function SwapForm(): Node {
const [isMarketOrder, setIsMarketOrder] = useState(true);
const [fromAsset, setFromAsset] = useState(defaultFromAsset);
const [toAsset, setToAsset] = useState(defaultToAsset);

// <TODO:CHECK_LINT>
// eslint-disable-next-line no-unused-vars
const handleOpenedDialog = type => setOpenedDialog(type);

const handleSwitchSelectedAssets = () => {
setFromAsset(toAsset);
setToAsset(fromAsset);
Expand Down

0 comments on commit 491ce02

Please sign in to comment.