Skip to content
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
Show file tree
Hide file tree
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 May 23, 2023
3a1f4a9
refactor: prototypes
rostislav-deriv May 23, 2023
487d761
refactor: better prototypes
rostislav-deriv May 23, 2023
abb959d
refactor: almost done w/o responsive and themes
rostislav-deriv May 24, 2023
479112e
refactor: tmp number formatting (better use hooks) + minor changes
rostislav-deriv May 24, 2023
afd164b
refactor: added a degree of responsiveness
rostislav-deriv May 24, 2023
1b35faf
refactor: line heights and font sizes
rostislav-deriv May 24, 2023
1cc7360
refactor: code improvement
rostislav-deriv May 24, 2023
2187f86
refactor: remove duplication in testing component
rostislav-deriv May 24, 2023
94133f4
refactor: adding FiatTransactionList with hardcoded list for now
rostislav-deriv May 25, 2023
054b898
refactor: Merge remote-tracking branch 'upstream/feature/wallets_with…
rostislav-deriv May 25, 2023
5860c2a
refactor: deriv/components deps
rostislav-deriv May 25, 2023
aa1bd7e
refactor: added hook for grouped transactions
rostislav-deriv May 26, 2023
3c76b77
refactor: add lodash.groupby and moment to hooks deps
rostislav-deriv May 26, 2023
43484a2
refactor: useGroupedFiatTransactions
rostislav-deriv May 26, 2023
9626403
refactor: visuals pretty much done w the grouping logic
rostislav-deriv May 26, 2023
7e115c9
refactor: add spec for hook
rostislav-deriv May 26, 2023
d71fbe0
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv May 27, 2023
6cfb764
refactor: move FiatTransactionList to modal
rostislav-deriv May 28, 2023
77f26b7
refactor: filling the gaps for transactions
rostislav-deriv May 28, 2023
4b91e48
refactor: API call for transactions added
rostislav-deriv May 29, 2023
2b90338
refactor: add logic for transfer transactions
rostislav-deriv May 29, 2023
278a952
refactor: minor change
rostislav-deriv May 29, 2023
d10e67f
refactor: switched to using WalletIcon
rostislav-deriv May 29, 2023
0d4933d
refactor: added is-crypto check for transfer transaction (other) acco…
rostislav-deriv May 29, 2023
806dee7
refactor: transaction list style change fix for later
rostislav-deriv May 30, 2023
c5db55a
refactor: transactions_ -> mock_transactions
rostislav-deriv May 30, 2023
2456d8f
refactor: types and logic
rostislav-deriv May 30, 2023
c19577e
refactor: better transactions.map(...)
rostislav-deriv May 30, 2023
8b6fca5
refactor: improved code
rostislav-deriv May 30, 2023
2926825
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv May 30, 2023
5e3215a
refactor: post-feat-branch-merge fixes
rostislav-deriv May 30, 2023
f75456a
refactor: remove unnecessary change
rostislav-deriv May 30, 2023
71ffbd3
refactor: hardcode app transactions
rostislav-deriv May 30, 2023
4f11fbf
refactor: remove seemingly redundant useCallbacks
rostislav-deriv May 30, 2023
232710c
refactor: TODO
rostislav-deriv May 30, 2023
e3fe3d9
refactor: fiat-transaction-list-item.tsx suggestions
rostislav-deriv May 31, 2023
f695d4a
refactor: some of the styles suggestions applied
rostislav-deriv May 31, 2023
b59a874
refactor: scss variable
rostislav-deriv May 31, 2023
77a7ea2
Update packages/appstore/src/components/fiat-transaction-list/fiat-tr…
rostislav-deriv May 31, 2023
d7b0a1e
Update packages/appstore/src/components/fiat-transaction-list/fiat-tr…
rostislav-deriv May 31, 2023
4c6cd9c
refactor: not styling direct html tags now
rostislav-deriv May 31, 2023
ac325ae
Merge remote-tracking branch 'origin/rostislav/WALL-641/transaction-l…
rostislav-deriv May 31, 2023
08fa506
refactor: move style import from index.ts to fiat-transaction-list.tsx
rostislav-deriv Jun 1, 2023
87714a4
refactor: app acc mock name change
rostislav-deriv Jun 1, 2023
f011ba2
refactor: isMobile() -> is_mobile
rostislav-deriv Jun 1, 2023
1f8dd8f
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv Jun 2, 2023
39ff7d6
refactor: separated fetching and grouping
rostislav-deriv Jun 2, 2023
0db0fd0
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv Jun 5, 2023
d33139b
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv Jun 5, 2023
6f7e536
Merge remote-tracking branch 'upstream/feature/wallets_with_traders_h…
rostislav-deriv Jun 6, 2023
591a914
refactor: account balance type fix
rostislav-deriv Jun 6, 2023
d70cde7
fix: tests fix
rostislav-deriv Jun 6, 2023
74a3fe3
refactor: switched back to using mock transaction list
rostislav-deriv Jun 7, 2023
842d725
refactor: update mock data
rostislav-deriv Jun 7, 2023
e72e3a3
refactor: fixes related to appearance
rostislav-deriv Jun 8, 2023
b5d90af
refactor: minor fix
rostislav-deriv Jun 8, 2023
429b4db
refactor: minor changes
rostislav-deriv Jun 8, 2023
b88d0d6
refactor: icons
rostislav-deriv Jun 8, 2023
0a8632c
refactor: changed wallet-icon.tsx + other small changes
rostislav-deriv Jun 9, 2023
9b87fa8
refactor: a fix for malta wallets
rostislav-deriv Jun 9, 2023
464c7f7
refactor: a few more appearance changes
rostislav-deriv Jun 9, 2023
b1cfb32
refactor: qa appearance fixes
rostislav-deriv Jun 12, 2023
abe00c3
refactor: deriv apps fix
rostislav-deriv Jun 12, 2023
b0045d4
refactor: real page fix
rostislav-deriv Jun 12, 2023
5ee845f
refactor: one more transaction
rostislav-deriv Jun 12, 2023
b006dd6
refactor: + initial deposit for real
rostislav-deriv Jun 12, 2023
79200bb
refactor: a few more changes to styles
rostislav-deriv Jun 12, 2023
9b7b532
refactor: a few more changes to styles
rostislav-deriv Jun 12, 2023
24118c8
refactor: z-index shenanigans
rostislav-deriv Jun 12, 2023
0c27696
refactor: app icon dark theme
rostislav-deriv Jun 13, 2023
d623f08
Merge branch 'feature/wallets_with_traders_hub' into rostislav/WALL-6…
rostislav-deriv Jun 13, 2023
1b3dc2c
refactor: package.json
rostislav-deriv Jun 13, 2023
6c22eac
refactor: (tmp) remove failing test
rostislav-deriv Jun 13, 2023
1fd6639
refactor: return failing test
rostislav-deriv Jun 13, 2023
69518cf
fix: tests
rostislav-deriv Jun 13, 2023
75db550
refactor: svg optimized
rostislav-deriv Jun 14, 2023
ab326f8
refactor: svg fixes
rostislav-deriv Jun 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/appstore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"license": "Apache-2.0",
"dependencies": {
"@deriv/account": "^1.0.0",
"@deriv/api": "^1.0.0",
"@deriv/api-types": "^1.0.94",
"@deriv/cashier": "^1.0.0",
"@deriv/components": "^1.0.0",
Expand All @@ -34,7 +35,6 @@
"@deriv/stores": "^1.0.0",
"@deriv/trader": "^3.8.0",
"@deriv/translations": "^1.0.0",
"@deriv/hooks": "^1.0.0",
Copy link
Contributor Author

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.

"@deriv/ui": "^0.8.0",
"classnames": "^2.2.6",
"formik": "^2.1.4",
Expand Down
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;
rostislav-deriv marked this conversation as resolved.
Show resolved Hide resolved
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;
}
}
}
}
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;
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;
15 changes: 15 additions & 0 deletions packages/appstore/src/modules/traders-hub/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ import classNames from 'classnames';
import WalletsBanner from 'Components/wallets-banner';
import './traders-hub.scss';
import WalletHeader from 'Components/wallet-header';
import FiatTransactionList from '../../components/fiat-transaction-list';

const FiatTransactionListDemo = () => {
return (
<FiatTransactionList
wallet={{
currency: 'usd',
icon: 'IcWalletCurrencyUsd',
icon_type: 'fiat',
}}
/>
);
};

const TradersHub = () => {
const { traders_hub, client, ui } = useStores();
Expand Down Expand Up @@ -104,6 +117,7 @@ const TradersHub = () => {
<div className='traders-hub__main-container'>
<OptionsAndMultipliersListing />
<CFDsListing />
<FiatTransactionListDemo />
</div>
</DesktopWrapper>
<MobileWrapper>
Expand All @@ -122,6 +136,7 @@ const TradersHub = () => {
)}
{selected_platform_type === 'options' && <OptionsAndMultipliersListing />}
{selected_platform_type === 'cfd' && <CFDsListing />}
<FiatTransactionListDemo />
</MobileWrapper>
<ModalManager />
{scrolled && <TourGuide />}
Expand Down
7 changes: 5 additions & 2 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
"dependencies": {
"@deriv/api": "^1.0.0",
"@deriv/stores": "^1.0.0",
"react": "^17.0.2"
"react": "^17.0.2",
"lodash.groupby": "^4.6.0",
"moment": "^2.29.2"
},
"devDependencies": {
"typescript": "^4.6.3",
"@testing-library/user-event": "^13.5.0",
"@testing-library/react": "^12.0.0",
"@testing-library/react-hooks": "^7.0.2"
"@testing-library/react-hooks": "^7.0.2",
"@types/lodash.groupby": "^4.6.7"
}
}
1 change: 1 addition & 0 deletions packages/hooks/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { default as useCFDRealAccounts } from './useCFDRealAccounts';
export { default as useCountdown } from './useCountdown';
export { default as useDepositLocked } from './useDepositLocked';
export { default as useExchangeRate } from './useExchangeRate';
export { default as useGroupedFiatTransactions } from './useGroupedFiatTransactions';
export { default as useHasActiveRealAccount } from './useHasActiveRealAccount';
export { default as useHasFiatCurrency } from './useHasFiatCurrency';
export { default as useHasMaltaInvestAccount } from './useHasMaltaInvestAccount';
Expand Down
92 changes: 92 additions & 0 deletions packages/hooks/src/useGroupedFiatTransactions.ts
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;
Loading