-
Notifications
You must be signed in to change notification settings - Fork 298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DTRA] Kate/Maryia/DTRA-1279/Redesign: Positions page #15234
Changes from 65 commits
d491b16
5319334
ef49019
b7249bd
e2ed78f
306b749
163829f
44bcd50
51fe756
8e843d3
4be88d0
146a56f
185a4bc
1609ba2
32e60f1
59e9b17
2e7c763
559182d
7ffc67e
4c4ced5
1437e77
6c5106b
db3f8d2
5e29ab9
6ad25f5
42dc7af
3a5dc29
13254e6
4abfa7d
7e4e35b
d1edd0c
3c699fe
29053e5
abd7ffd
e0e6896
06c9356
c56fb28
c36e3ae
132fe7b
b6e45fb
2105c28
588856c
336c62c
4906b00
b38274e
2f79d0a
28f35b3
1be30a2
823d896
e640142
6e0d5a3
096946b
134e067
8581ea2
0826f6c
70b2058
82a2c35
fc343cd
85f0fdd
75e0e40
3b69cd1
81ee2d0
1a677eb
ebcd0df
8d622f5
3c37e0b
9217413
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -655,8 +655,7 @@ const OpenPositions = observer(({ component_icon, ...props }: TOpenPositions) => | |
/> | ||
); | ||
}; | ||
// TODO: Uncomment and update this when DTrader 2.0 development starts: | ||
// if (useFeatureFlags().is_dtrader_v2_enabled) return <Text size='l'>I am Open positions for DTrader 2.0.</Text>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's unlikely that we're gonna do the redesign of reports under dtrader_v2 flag. this comment doesn't seem necessary anymore. |
||
|
||
return ( | ||
<React.Fragment> | ||
<NotificationMessages /> | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { formatMoney, toMoment, getSymbolDisplayName, getMarketInformation } from '@deriv/shared'; | ||
import { ActiveSymbols, ProfitTable } from '@deriv/api-types'; | ||
|
||
export type TTransaction = NonNullable<NonNullable<ProfitTable>['transactions']>[number]; | ||
|
||
export const formatProfitTableTransactions = ( | ||
transaction: TTransaction, | ||
currency: string, | ||
active_symbols: ActiveSymbols = [] | ||
) => { | ||
const format_string = 'DD MMM YYYY HH:mm:ss'; | ||
const purchase_time = | ||
transaction.purchase_time && `${toMoment(Number(transaction.purchase_time)).format(format_string)}`; | ||
const purchase_time_unix = transaction.purchase_time; | ||
const sell_time = transaction.sell_time && `${toMoment(Number(transaction.sell_time)).format(format_string)}`; | ||
const payout = transaction.payout ?? NaN; | ||
const sell_price = transaction.sell_price ?? NaN; | ||
const buy_price = transaction.buy_price ?? NaN; | ||
const profit_loss = formatMoney(currency, Number(sell_price - buy_price), true); | ||
const display_name = getSymbolDisplayName( | ||
active_symbols, | ||
getMarketInformation(transaction.shortcode ?? '').underlying | ||
); | ||
|
||
return { | ||
...transaction, | ||
...{ | ||
payout, | ||
sell_price, | ||
buy_price, | ||
profit_loss, | ||
sell_time, | ||
purchase_time, | ||
display_name, | ||
purchase_time_unix, | ||
}, | ||
}; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a copy of the same migrated file from https://github.com/binary-com/deriv-app/pull/15327/files. Copied to avoid a conflict. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,7 +203,7 @@ export const getCurrentTick = (contract_info: TContractInfo) => { | |
const current_tick = | ||
isDigitContract(contract_info.contract_type) || isAsiansContract(contract_info.contract_type) | ||
? tick_stream.length | ||
: tick_stream.length - 1; | ||
: contract_info.tick_passed ?? tick_stream.length - 1; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the change is needed to make this helper work for ACCU contracts as well. |
||
return !current_tick || current_tick < 0 ? 0 : current_tick; | ||
}; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,39 +3,45 @@ import { NavLink } from 'react-router-dom'; | |
import { findRouteByPath, normalizePath } from './helpers'; | ||
import getRoutesConfig from '../../Constants/routes-config'; | ||
|
||
type TBinaryLinkProps = React.PropsWithChildren<{ | ||
active_class?: string; | ||
className?: string; | ||
to?: string; | ||
onClick?: () => void; | ||
}>; | ||
type TBinaryLinkProps = Omit<React.HTMLProps<HTMLAnchorElement>, 'title' | 'ref'> & | ||
React.PropsWithChildren<{ | ||
active_class?: string; | ||
className?: string; | ||
to?: string; | ||
onClick?: () => void; | ||
}>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here we updated the props type in order to be able to pass some native event handlers like |
||
|
||
// TODO: solve circular dependency problem | ||
// when binary link is imported into components present in routes config | ||
// or into their descendants | ||
const BinaryLink = ({ active_class = '', to, children, ...props }: TBinaryLinkProps) => { | ||
const path = normalizePath(to); | ||
const route = findRouteByPath(path, getRoutesConfig()); | ||
const BinaryLink = React.forwardRef<HTMLAnchorElement, TBinaryLinkProps>( | ||
({ active_class = '', to, children, ...props }, ref) => { | ||
const path = normalizePath(to); | ||
const route = findRouteByPath(path, getRoutesConfig()); | ||
|
||
if (!route) { | ||
throw new Error(`Route not found: ${to}`); | ||
if (!route) { | ||
throw new Error(`Route not found: ${to}`); | ||
} | ||
|
||
return to ? ( | ||
<NavLink | ||
data-testid='dt_binary_link' | ||
to={path} | ||
activeClassName={active_class || 'active'} | ||
exact={route.exact} | ||
ref={ref} | ||
{...props} | ||
> | ||
{children} | ||
</NavLink> | ||
) : ( | ||
<a data-testid='dt_binary_link' ref={ref} {...props}> | ||
{children} | ||
</a> | ||
); | ||
} | ||
); | ||
|
||
return to ? ( | ||
<NavLink | ||
data-testid='dt_binary_link' | ||
to={path} | ||
activeClassName={active_class || 'active'} | ||
exact={route.exact} | ||
{...props} | ||
> | ||
{children} | ||
</NavLink> | ||
) : ( | ||
<a data-testid='dt_binary_link' {...props}> | ||
{children} | ||
</a> | ||
); | ||
}; | ||
BinaryLink.displayName = 'BinaryLink'; | ||
|
||
export default BinaryLink; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extended the component functionality with the
as
prop in order to substitute thediv
tag with aspan
and avoid a console error 'div cannot be a descendant of p' that is thrown when it's adiv
because we are passingRemainingTime
inContractCardStatusTimer
down to theTag
component fromquill-ui
library where it rendersRemainingTime
as alabel
insidep
tag.