-
Notifications
You must be signed in to change notification settings - Fork 299
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
Rostislav / WALL-454 / Fiat transaction list (post feature branch update) #8753
Merged
nijil-deriv
merged 78 commits into
binary-com:feature/wallets_with_traders_hub
from
rostislav-deriv:rostislav/WALL-641/transaction-list-item-new
Jun 14, 2023
Merged
Changes from 16 commits
Commits
Show all changes
78 commits
Select commit
Hold shift + click to select a range
183e8c9
refactor: add DeepRequired for use
rostislav-deriv 3a1f4a9
refactor: prototypes
rostislav-deriv 487d761
refactor: better prototypes
rostislav-deriv abb959d
refactor: almost done w/o responsive and themes
rostislav-deriv 479112e
refactor: tmp number formatting (better use hooks) + minor changes
rostislav-deriv afd164b
refactor: added a degree of responsiveness
rostislav-deriv 1b35faf
refactor: line heights and font sizes
rostislav-deriv 1cc7360
refactor: code improvement
rostislav-deriv 2187f86
refactor: remove duplication in testing component
rostislav-deriv 94133f4
refactor: adding FiatTransactionList with hardcoded list for now
rostislav-deriv 054b898
refactor: Merge remote-tracking branch 'upstream/feature/wallets_with…
rostislav-deriv 5860c2a
refactor: deriv/components deps
rostislav-deriv aa1bd7e
refactor: added hook for grouped transactions
rostislav-deriv 3c76b77
refactor: add lodash.groupby and moment to hooks deps
rostislav-deriv 43484a2
refactor: useGroupedFiatTransactions
rostislav-deriv 9626403
refactor: visuals pretty much done w the grouping logic
rostislav-deriv 7e115c9
refactor: add spec for hook
rostislav-deriv d71fbe0
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv 6cfb764
refactor: move FiatTransactionList to modal
rostislav-deriv 77f26b7
refactor: filling the gaps for transactions
rostislav-deriv 4b91e48
refactor: API call for transactions added
rostislav-deriv 2b90338
refactor: add logic for transfer transactions
rostislav-deriv 278a952
refactor: minor change
rostislav-deriv d10e67f
refactor: switched to using WalletIcon
rostislav-deriv 0d4933d
refactor: added is-crypto check for transfer transaction (other) acco…
rostislav-deriv 806dee7
refactor: transaction list style change fix for later
rostislav-deriv c5db55a
refactor: transactions_ -> mock_transactions
rostislav-deriv 2456d8f
refactor: types and logic
rostislav-deriv c19577e
refactor: better transactions.map(...)
rostislav-deriv 8b6fca5
refactor: improved code
rostislav-deriv 2926825
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv 5e3215a
refactor: post-feat-branch-merge fixes
rostislav-deriv f75456a
refactor: remove unnecessary change
rostislav-deriv 71ffbd3
refactor: hardcode app transactions
rostislav-deriv 4f11fbf
refactor: remove seemingly redundant useCallbacks
rostislav-deriv 232710c
refactor: TODO
rostislav-deriv e3fe3d9
refactor: fiat-transaction-list-item.tsx suggestions
rostislav-deriv f695d4a
refactor: some of the styles suggestions applied
rostislav-deriv b59a874
refactor: scss variable
rostislav-deriv 77a7ea2
Update packages/appstore/src/components/fiat-transaction-list/fiat-tr…
rostislav-deriv d7b0a1e
Update packages/appstore/src/components/fiat-transaction-list/fiat-tr…
rostislav-deriv 4c6cd9c
refactor: not styling direct html tags now
rostislav-deriv ac325ae
Merge remote-tracking branch 'origin/rostislav/WALL-641/transaction-l…
rostislav-deriv 08fa506
refactor: move style import from index.ts to fiat-transaction-list.tsx
rostislav-deriv 87714a4
refactor: app acc mock name change
rostislav-deriv f011ba2
refactor: isMobile() -> is_mobile
rostislav-deriv 1f8dd8f
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv 39ff7d6
refactor: separated fetching and grouping
rostislav-deriv 0db0fd0
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv d33139b
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv 6f7e536
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv 591a914
refactor: account balance type fix
rostislav-deriv d70cde7
fix: tests fix
rostislav-deriv 74a3fe3
refactor: switched back to using mock transaction list
rostislav-deriv 842d725
refactor: update mock data
rostislav-deriv e72e3a3
refactor: fixes related to appearance
rostislav-deriv b5d90af
refactor: minor fix
rostislav-deriv 429b4db
refactor: minor changes
rostislav-deriv b88d0d6
refactor: icons
rostislav-deriv 0a8632c
refactor: changed wallet-icon.tsx + other small changes
rostislav-deriv 9b87fa8
refactor: a fix for malta wallets
rostislav-deriv 464c7f7
refactor: a few more appearance changes
rostislav-deriv b1cfb32
refactor: qa appearance fixes
rostislav-deriv abe00c3
refactor: deriv apps fix
rostislav-deriv b0045d4
refactor: real page fix
rostislav-deriv 5ee845f
refactor: one more transaction
rostislav-deriv b006dd6
refactor: + initial deposit for real
rostislav-deriv 79200bb
refactor: a few more changes to styles
rostislav-deriv 9b7b532
refactor: a few more changes to styles
rostislav-deriv 24118c8
refactor: z-index shenanigans
rostislav-deriv 0c27696
refactor: app icon dark theme
rostislav-deriv d623f08
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv 1b3dc2c
refactor: package.json
rostislav-deriv 6c22eac
refactor: (tmp) remove failing test
rostislav-deriv 1fd6639
refactor: return failing test
rostislav-deriv 69518cf
fix: tests
rostislav-deriv 75db550
refactor: svg optimized
rostislav-deriv ab326f8
refactor: svg fixes
rostislav-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/appstore/src/components/fiat-transaction-list/fiat-transaction-list-item.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import React, { useCallback } from 'react'; | ||
import { Statement } from '@deriv/api-types'; | ||
import { isMobile } from '@deriv/shared'; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { Text, WalletCard } from '@deriv/components'; | ||
|
||
type StatementTransaction = DeepRequired<Statement>['transactions'][number]; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
type TFiatTransactionListItem = Pick<StatementTransaction, 'amount' | 'balance_after'> & { | ||
action_type: | ||
| (StatementTransaction['action_type'] & ('deposit' | 'withdrawal' | 'transfer')) | ||
| 'initial_fund' | ||
| 'reset_balance'; | ||
account_name: string; | ||
currency: string; | ||
wallet: any; | ||
}; | ||
|
||
const FiatTransactionListItem = ({ | ||
account_name, | ||
action_type, | ||
amount, | ||
balance_after, | ||
currency, | ||
wallet, | ||
}: TFiatTransactionListItem) => { | ||
const formatAmount = useCallback( | ||
(value: number) => value.toLocaleString(undefined, { minimumFractionDigits: 2 }), | ||
[] | ||
); | ||
|
||
const formatActionType = useCallback( | ||
(value: string) => value[0].toUpperCase() + value.substring(1).replace(/_/, ' '), | ||
[] | ||
); | ||
|
||
return ( | ||
<div className='fiat-transaction-list__item'> | ||
<div> | ||
<WalletCard wallet={wallet} size='small' /> | ||
<span> | ||
<Text | ||
size={isMobile() ? 'xxxs' : 'xxs'} | ||
color='less-prominent' | ||
weight='lighter' | ||
line_height={isMobile() ? 's' : 'm'} | ||
> | ||
{formatActionType(action_type)} | ||
</Text> | ||
<Text | ||
size={isMobile() ? 'xxxs' : 'xxs'} | ||
color='prominent' | ||
weight='bold' | ||
line_height={isMobile() ? 's' : 'm'} | ||
> | ||
{account_name} | ||
</Text> | ||
</span> | ||
</div> | ||
<span> | ||
<Text | ||
size={isMobile() ? 'xxxs' : 'xxs'} | ||
color={amount > 0 ? 'profit-success' : 'loss-danger'} | ||
weight='bold' | ||
line_height={isMobile() ? 's' : 'm'} | ||
> | ||
{(amount > 0 ? '+' : '') + formatAmount(amount)} {currency} | ||
</Text> | ||
<Text | ||
size={isMobile() ? 'xxxxs' : 'xxxs'} | ||
color='less-prominent' | ||
weight='lighter' | ||
line_height={isMobile() ? 'm' : 's'} | ||
> | ||
Balance: {formatAmount(balance_after)} {currency} | ||
</Text> | ||
</span> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FiatTransactionListItem; |
46 changes: 46 additions & 0 deletions
46
packages/appstore/src/components/fiat-transaction-list/fiat-transaction-list.scss
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
.fiat-transaction-list { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 8px; | ||
|
||
&__day { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
& > span { | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
padding: 8px 16px; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
& > div { | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
box-shadow: inset 0 1px 0 #f2f3f4; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
|
||
&__item { | ||
display: flex; | ||
flex-direction: row; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
justify-content: space-between; | ||
align-items: center; | ||
height: 72px; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
padding: 16px; | ||
|
||
& span { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: end; | ||
gap: 4px; | ||
} | ||
|
||
& div { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 8px; | ||
|
||
& span { | ||
align-items: start; | ||
justify-content: center; | ||
gap: 0; | ||
} | ||
} | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/appstore/src/components/fiat-transaction-list/fiat-transaction-list.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import React from 'react'; | ||
import { Statement } from '@deriv/api-types'; | ||
import { isMobile } from '@deriv/shared'; | ||
import { Text } from '@deriv/components'; | ||
import { useGroupedFiatTransactions } from '@deriv/hooks'; | ||
import FiatTransactionListItem from './fiat-transaction-list-item'; | ||
|
||
type TFiatTransactionListProps = { | ||
wallet: any; | ||
}; | ||
|
||
const FiatTransactionList = ({ wallet }: TFiatTransactionListProps) => { | ||
const grouped_transactions = useGroupedFiatTransactions(); | ||
|
||
const TransactionsForADay = ({ | ||
day, | ||
transactions, | ||
}: { | ||
day: string; | ||
transactions: Required<Statement>['transactions']; | ||
}) => { | ||
return ( | ||
<div className='fiat-transaction-list__day'> | ||
<Text | ||
size={isMobile() ? 'xxxxs' : 'xxxs'} | ||
line_height={isMobile() ? 'm' : 's'} | ||
color='less-prominent' | ||
weight='lighter' | ||
> | ||
{day} | ||
</Text> | ||
{transactions | ||
.map(transaction => { | ||
if ( | ||
transaction.amount === undefined || | ||
transaction.balance_after === undefined || | ||
transaction.action_type === undefined | ||
) | ||
return null; | ||
return ( | ||
<FiatTransactionListItem | ||
key={transaction.transaction_id} | ||
action_type={ | ||
transaction.action_type as React.ComponentProps< | ||
typeof FiatTransactionListItem | ||
>['action_type'] | ||
} | ||
account_name={'TODO get from store'} | ||
amount={transaction.amount} | ||
balance_after={transaction.balance_after} | ||
currency={'TODO'} | ||
wallet={wallet} | ||
/> | ||
); | ||
}) | ||
.filter(Boolean)} | ||
</div> | ||
); | ||
}; | ||
|
||
return ( | ||
<div className='fiat-transaction-list'> | ||
{Object.entries(grouped_transactions).map(([day, transactions]) => ( | ||
<TransactionsForADay | ||
key={day} | ||
day={day} | ||
transactions={transactions as Required<Statement>['transactions']} | ||
/> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default FiatTransactionList; |
4 changes: 4 additions & 0 deletions
4
packages/appstore/src/components/fiat-transaction-list/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import FiatTransactionList from './fiat-transaction-list'; | ||
import './fiat-transaction-list.scss'; | ||
rostislav-deriv marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export default FiatTransactionList; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import _ from 'lodash'; | ||
import moment from 'moment'; | ||
|
||
const useGroupedFiatTransactions = () => { | ||
// TODO: don't hardcode, replace with ... = useFetch('statement'); | ||
const transactions = [ | ||
{ | ||
action_type: 'initial_fund', | ||
amount: 42, | ||
app_id: 1, | ||
balance_after: 42, | ||
contract_id: 6842558021, | ||
longcode: 'Win payout if AUD/JPY is strictly higher than entry spot at 1 minute after contract start time.', | ||
payout: 1, | ||
reference_id: {}, | ||
shortcode: 'CALL_FRXAUDJPY_1_1470637406_1470637466_S0P_0', | ||
transaction_id: 13693011401, | ||
transaction_time: 1685109944, | ||
}, | ||
{ | ||
action_type: 'reset_balance', | ||
amount: -42, | ||
app_id: 2, | ||
balance_after: 0, | ||
contract_id: 6842548881, | ||
longcode: 'Win payout if AUD/JPY is strictly lower than entry spot at 1 minute after contract start time.', | ||
payout: 1, | ||
purchase_time: 1470637295, | ||
reference_id: 13692993001, | ||
shortcode: 'PUT_FRXAUDJPY_1_1470637295_1470637355_S0P_0', | ||
transaction_id: 13693003421, | ||
transaction_time: 1685109944, | ||
}, | ||
{ | ||
action_type: 'deposit', | ||
amount: 2, | ||
app_id: {}, | ||
balance_after: 44.24, | ||
contract_id: {}, | ||
longcode: 'Payment from Binary Services Ltd Apr 2017', | ||
payout: {}, | ||
reference_id: {}, | ||
shortcode: {}, | ||
transaction_id: 17494117541, | ||
transaction_time: 1685009944, | ||
}, | ||
{ | ||
action_type: 'withdrawal', | ||
amount: -5.55, | ||
app_id: {}, | ||
balance_after: 0, | ||
contract_id: {}, | ||
longcode: 'Account closed. Please contact customer support for assistance.', | ||
payout: {}, | ||
reference_id: {}, | ||
shortcode: {}, | ||
transaction_id: 17494415481, | ||
transaction_time: 1684009944, | ||
}, | ||
{ | ||
action_type: 'transfer', | ||
amount: 5.55, | ||
from: { | ||
loginid: '', | ||
type: 'trading', | ||
}, | ||
to: { | ||
loginid: '', | ||
type: 'wallet', | ||
}, | ||
app_id: {}, | ||
balance_after: 5.55, | ||
contract_id: {}, | ||
longcode: 'Transfer from <> to <>. Includes fees', | ||
payout: {}, | ||
reference_id: {}, | ||
shortcode: {}, | ||
transaction_id: 17494415481, | ||
transaction_time: 1684009944, | ||
}, | ||
]; | ||
|
||
const grouped_transactions = _.groupBy(transactions, transaction => | ||
moment(transaction.transaction_time * 1000) | ||
.startOf('day') | ||
.format('DD MMM YYYY') | ||
); | ||
|
||
return grouped_transactions; | ||
}; | ||
|
||
export default useGroupedFiatTransactions; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Already present in file a few lines above.