Skip to content

Commit

Permalink
Fix application error
Browse files Browse the repository at this point in the history
  • Loading branch information
koredefashokun committed Jul 7, 2023
1 parent c000472 commit 9defebe
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 36 deletions.
10 changes: 5 additions & 5 deletions packages/app/src/components/ColoredPrice.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import styled from 'styled-components'

import { PricesInfo } from 'state/prices/types'
import { PriceChange } from 'state/prices/types'

export const getColorFromPriceInfo = (priceInfo: PricesInfo | undefined) => {
return !priceInfo?.change ? 'white' : priceInfo.change === 'up' ? 'green' : 'red'
export const getColorFromPriceInfo = (change?: PriceChange) => {
return !change ? 'white' : change === 'up' ? 'green' : 'red'
}

const ColoredPrice = styled.div<{ priceInfo: PricesInfo | undefined }>`
const ColoredPrice = styled.div<{ priceChange?: PriceChange }>`
font-size: 13px;
font-family: ${(props) => props.theme.fonts.mono};
color: ${(props) => {
const color = getColorFromPriceInfo(props.priceInfo)
const color = getColorFromPriceInfo(props.priceChange)

Check warning on line 13 in packages/app/src/components/ColoredPrice.tsx

View check run for this annotation

Codecov / codecov/patch

packages/app/src/components/ColoredPrice.tsx#L13

Added line #L13 was not covered by tests
return props.theme.colors.selectedTheme[color]
}};
`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ const FuturesMarketsTable: React.FC<FuturesMarketsTableProps> = ({ search }) =>
accessorKey: 'price',
cell: (cellProps) => {
return (
<ColoredPrice priceInfo={cellProps.row.original.priceInfo}>
<ColoredPrice priceChange={cellProps.row.original.priceInfo?.change}>
{formatDollars(cellProps.row.original.price, { suggestDecimals: true })}
</ColoredPrice>
)
Expand Down
8 changes: 3 additions & 5 deletions packages/app/src/sections/dashboard/PortfolioChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ const PortfolioChart: FC = () => {
<Timeframe />
</TimeframeOverlay>
</TopBar>
<StyledPriceChart setHoverValue={setHoverValue} setHoverTitle={setHoverTitle} />
<PriceChart setHoverValue={setHoverValue} setHoverTitle={setHoverTitle} />
</ChartContainer>
) : (
<ChartContainer>
Expand All @@ -233,7 +233,7 @@ const PortfolioChart: FC = () => {
<Timeframe />
</TimeframeOverlay>
</TopBar>
<StyledPriceChart setHoverValue={setHoverValue} setHoverTitle={setHoverTitle} />
<PriceChart setHoverValue={setHoverValue} setHoverTitle={setHoverTitle} />
</ChartContainer>
</MobileChartGrid>
) : (
Expand Down Expand Up @@ -267,8 +267,6 @@ const TopBar = styled.div`
padding: 8px 8px 0 0;
`

const StyledPriceChart = styled(PriceChart)``

const ChartOverlay = styled.div`
display: flex;
flex-direction: column;
Expand All @@ -288,7 +286,7 @@ const TimeframeOverlay = styled.div`
max-width: 192px;
`

const PortfolioTitle = styled(Body).attrs({ weight: 'bold' })`
const PortfolioTitle = styled(Body)`
color: ${(props) => props.theme.colors.selectedTheme.gray};
font-size: 16px;
margin-bottom: 4px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ const MarketPriceDetail: React.FC<MarketDetailsProps> = memo(({ mobile }) => {
return (
<MarketDetail
mobile={mobile}
color={getColorFromPriceInfo(markPrice)}
color={getColorFromPriceInfo(markPrice?.change)}
value={markPrice ? formatDollars(markPrice.price, { suggestDecimals: true }) : NO_VALUE}
dataKey={MarketDataKey.marketPrice}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const ConditionalOrdersTab: React.FC = () => {
<OrderRow>
<Body color="secondary">Chainlink Price</Body>
{order.currentPrice?.price ? (
<ColoredPrice priceInfo={order.currentPrice}>
<ColoredPrice priceChange={order.currentPrice.change}>

Check warning on line 95 in packages/app/src/sections/futures/MobileTrade/UserTabs/ConditionalOrdersTab.tsx

View check run for this annotation

Codecov / codecov/patch

packages/app/src/sections/futures/MobileTrade/UserTabs/ConditionalOrdersTab.tsx#L95

Added line #L95 was not covered by tests
{formatDollars(order.currentPrice.price)}
</ColoredPrice>
) : (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,7 @@ const TransfersTab: React.FC = () => {

return (
<ColoredPrice
priceInfo={{
price: wei(cellProps.row.original.size),
change: cellProps.row.original.action === 'deposit' ? 'up' : 'down',
}}
priceChange={cellProps.row.original.action === 'deposit' ? 'up' : 'down'}
>
{cellProps.row.original.action === 'deposit' ? '+' : ''}
{formatDollars(cellProps.row.original.size, formatOptions)}
Expand Down
7 changes: 1 addition & 6 deletions packages/app/src/sections/futures/Trade/MarketsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,7 @@ const MarketsDropdown: React.FC<MarketsDropdownProps> = ({ mobile }) => {
cell: (cellProps) => {

Check warning on line 259 in packages/app/src/sections/futures/Trade/MarketsDropdown.tsx

View check run for this annotation

Codecov / codecov/patch

packages/app/src/sections/futures/Trade/MarketsDropdown.tsx#L259

Added line #L259 was not covered by tests
return (
<div>
<ColoredPrice
priceInfo={{
price: wei(cellProps.row.original.price),
change: cellProps.row.original.priceDirection,
}}
>
<ColoredPrice priceChange={cellProps.row.original.priceDirection}>
{cellProps.row.original.price}
</ColoredPrice>
</div>
Expand Down
10 changes: 4 additions & 6 deletions packages/app/src/sections/futures/Trades/Trades.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,7 @@ const Trades = memo(() => {
return cellProps.getValue().eq(0) ? (
'--'
) : (
<ColoredPrice
priceInfo={{
price: cellProps.getValue(),
change: cellProps.getValue().gt(0) ? 'up' : 'down',
}}
>
<ColoredPrice priceChange={cellProps.getValue().gt(0) ? 'up' : 'down'}>
{formatDollars(cellProps.getValue(), { maxDecimals: 2 })}
</ColoredPrice>
)
Expand Down Expand Up @@ -184,6 +179,9 @@ const Trades = memo(() => {
size: 100,
},
{
header: () => (
<TableHeader>{t('futures.market.user.trades.table.transaction')}</TableHeader>
),
accessorKey: 'txnHash',
cell: (cellProps) => (
<StyledExternalLink href={blockExplorer.txLink(cellProps.getValue())}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const TradesHistoryTable: FC<TradesHistoryTableProps> = ({ mobile }) => {
minDecimals: numDecimals,
truncateOver: 1e6,
})}{' '}
${normal ? '💀' : ''}
{normal ? '💀' : ''}
</DirectionalValue>
)
},
Expand Down
5 changes: 1 addition & 4 deletions packages/app/src/sections/futures/Transfers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ const Transfers: FC = () => {

return (
<ColoredPrice
priceInfo={{
price: cellProps.row.original.size,
change: cellProps.row.original.action === 'deposit' ? 'up' : 'down',
}}
priceChange={cellProps.row.original.action === 'deposit' ? 'up' : 'down'}
>
{cellProps.row.original.action === 'deposit' ? '+' : ''}
{formatDollars(cellProps.row.original.size, formatOptions)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default function ConditionalOrdersTable() {
cell: (cellProps) => {

Check warning on line 150 in packages/app/src/sections/futures/UserInfo/ConditionalOrdersTable.tsx

View check run for this annotation

Codecov / codecov/patch

packages/app/src/sections/futures/UserInfo/ConditionalOrdersTable.tsx#L150

Added line #L150 was not covered by tests
return cellProps.row.original.currentPrice ? (
<div>
<ColoredPrice priceInfo={cellProps.row.original.currentPrice}>
<ColoredPrice priceChange={cellProps.row.original.currentPrice.change}>
{formatDollars(cellProps.row.original.currentPrice.price, {
suggestDecimals: true,
})}
Expand Down
3 changes: 2 additions & 1 deletion packages/app/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@
"insufficient-margin": "Leverage cannot be increased, it exceeds the minimum margin requirement of $40",
"insufficient-free-margin": "Leverage cannot be modified, please deposit more margin or reduce open position sizes"
},
"edit-position":{
"edit-position": {
"market": "Market",
"current-size": "Current size",
"leverage-change": "Leverage",
Expand Down Expand Up @@ -1070,6 +1070,7 @@
"side-type": "Side/Type",
"no-results": "You have no trade history",
"order-type": "order type",
"transaction": "Transaction",
"trade-types": {
"exit": "exit",
"liquidated": "liquidated",
Expand Down

0 comments on commit 9defebe

Please sign in to comment.