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

Release version to master #765

Merged
merged 230 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
230 commits
Select commit Hold shift + click to select a range
b760037
Add filter summary icon
alexstotsky Dec 14, 2023
97ef3d7
Add minimum balance related keys/descriptions
alexstotsky Dec 14, 2023
1a2f75b
Actualize icons export
alexstotsky Dec 14, 2023
b05b520
Update summary by asset constants
alexstotsky Jan 4, 2024
e240b5d
Add setMinimumBalance action
alexstotsky Jan 4, 2024
f96efe7
Actualize reducers handling cases, update initial state
alexstotsky Jan 4, 2024
9290f60
Implement minimum balance selector
alexstotsky Jan 4, 2024
11c8815
Enhance input type number appearance
alexstotsky Jan 4, 2024
96afcf3
[wip] Summary by asset filters
alexstotsky Jan 4, 2024
b33d1c6
Add filters to summary by asset section
alexstotsky Jan 4, 2024
03ac2fb
Update summary filter icon
alexstotsky Jan 4, 2024
a395993
Fix minimum balance getter
alexstotsky Jan 4, 2024
ff3c331
Adjust summary filters positioning
alexstotsky Jan 4, 2024
346e194
Adjust summery filters row
alexstotsky Jan 4, 2024
1266ecc
Update summary constants
alexstotsky Jan 4, 2024
70abf66
Add min balance usage action
alexstotsky Jan 4, 2024
cd88dab
Update summary by asset reducers
alexstotsky Jan 4, 2024
37612ed
Add getUseMinBalance selector
alexstotsky Jan 4, 2024
eeeeb88
[wip] Summary filters handlers
alexstotsky Jan 4, 2024
414bf32
Adjust summary filter icon
alexstotsky Jan 5, 2024
d0d93a0
Add summery filters btn styling
alexstotsky Jan 5, 2024
394370f
Add summary filter button
alexstotsky Jan 5, 2024
1d9c02f
Improve filters icon positioning and styling
alexstotsky Jan 5, 2024
bbf6515
Actualize colors and on hover behavior
alexstotsky Jan 5, 2024
b3a8138
Rework and improve summary by asset titles section
alexstotsky Jan 5, 2024
3ba54e7
Fix summary filters modal positioning
alexstotsky Jan 5, 2024
9f1416c
Fix filter flickering on refresh
alexstotsky Jan 8, 2024
fc8b38b
Adjust icon config
alexstotsky Jan 8, 2024
94cce80
Actualize filters active state styling
alexstotsky Jan 8, 2024
4359efc
Add summary filters popover menu styling
alexstotsky Jan 8, 2024
398799f
Switch row and title styling
alexstotsky Jan 8, 2024
6fb2b50
Add summary filters row and title
alexstotsky Jan 8, 2024
761611f
Add min balance imput label
alexstotsky Jan 8, 2024
9f9badc
Actualize imput label styling
alexstotsky Jan 8, 2024
8b8eb70
Add balance usage switch, update positioning
alexstotsky Jan 8, 2024
c4c700a
Update themes
alexstotsky Jan 8, 2024
46d7ee4
Actualize switch btn representation
alexstotsky Jan 8, 2024
da2b085
Update swicth config
alexstotsky Jan 8, 2024
d05e0b9
Fix indicator alignment
alexstotsky Jan 8, 2024
e1c0d45
Rework toggling min balance action
alexstotsky Jan 8, 2024
c8580cd
Update by asset constants
alexstotsky Jan 8, 2024
d03585a
Implement minimum balance usage toggling
alexstotsky Jan 8, 2024
6c9d33b
Actualize summary by asset reducers cases
alexstotsky Jan 8, 2024
7342436
Update switch classes, cleanup
alexstotsky Jan 8, 2024
cbf1d96
Fix classes
alexstotsky Jan 8, 2024
6408d4b
Improve switch active state representation
alexstotsky Jan 8, 2024
b5f77b4
Update use min balance initial state
alexstotsky Jan 9, 2024
a83722c
Add minimum balance input
alexstotsky Jan 9, 2024
3043bad
Fix input key values types related warnings
alexstotsky Jan 9, 2024
8e1a8dc
Allow optional labels for input keys
alexstotsky Jan 9, 2024
cc2883d
Adjust initial minimum balance
alexstotsky Jan 9, 2024
de89b9b
Implement balance changing flow
alexstotsky Jan 9, 2024
836f5c8
Add customizable disabled state for input key
alexstotsky Jan 9, 2024
e56d6e3
Claenup
alexstotsky Jan 9, 2024
df9b7de
Adjust minimum balance input styling
alexstotsky Jan 9, 2024
2e1b5c6
Implement minimum balance disabled state handling and representation
alexstotsky Jan 9, 2024
1b02cf9
Add input balance currency icon
alexstotsky Jan 9, 2024
474bc6a
Implement currency type styling and positioning
alexstotsky Jan 9, 2024
6dddbb2
Update getMinimumBalance selector
alexstotsky Jan 9, 2024
1ecea78
Improve balance value handling
alexstotsky Jan 9, 2024
df84411
Update summary by asset reducers
alexstotsky Jan 9, 2024
52a7c60
Update balance target value setting
alexstotsky Jan 9, 2024
1697bdd
Actualize prepareSummaryByAssetData handler
alexstotsky Jan 9, 2024
b58dca1
Implement minimum balances handling flow
alexstotsky Jan 9, 2024
d7b7a6e
Improve merged entries filtering flow
alexstotsky Jan 9, 2024
4a033be
Lint fix
alexstotsky Jan 10, 2024
9693da9
Cleanup
alexstotsky Jan 10, 2024
faecf7c
Update getUseMinBalance selector default
alexstotsky Jan 11, 2024
7e842ba
Bump follow-redirects from 1.15.3 to 1.15.4
dependabot[bot] Jan 10, 2024
3af7acb
Merge pull request #753 from alexstotsky/show-minimum-balance
ezewer Jan 17, 2024
fc6f950
Merge pull request #755 from alexstotsky/actualize-fllow-redirects
ezewer Jan 17, 2024
b6c1f73
Add maintenance mode related constants
Oct 9, 2023
370fddc
Fix ws actions prefixes
Oct 9, 2023
4cdc12f
Update base constants
alexstotsky Jan 11, 2024
09bef60
Add showMaintenanceModal action
alexstotsky Jan 11, 2024
e914f7a
Update base reducers handling cases and initial entries
alexstotsky Jan 11, 2024
f665de4
Implement maintenance mode handling ws sagas
alexstotsky Jan 11, 2024
b803c9b
[wip] Maintenance modal
alexstotsky Jan 15, 2024
7a5144b
Add maintenance modal styling
alexstotsky Jan 15, 2024
d748e96
Update main styles import
alexstotsky Jan 15, 2024
69c2a11
Add maintenance keys/descriptions
alexstotsky Jan 15, 2024
554247a
Add maintenace dialog for the app mode to the main
alexstotsky Jan 15, 2024
822df70
Add bfx status link const
alexstotsky Jan 15, 2024
7b5b988
Implement getShowMaintenanceModal selector
alexstotsky Jan 15, 2024
094e246
Update classnames, cleanup
alexstotsky Jan 15, 2024
50515cc
Redundant container cleanup
alexstotsky Jan 15, 2024
4f37979
Fix maintenance dialog export
alexstotsky Jan 15, 2024
b2252c3
Update locales
alexstotsky Jan 15, 2024
6084878
Implement maintenance notice
alexstotsky Jan 15, 2024
10490cc
Improve status page link config
alexstotsky Jan 15, 2024
d610a43
Lint fix
alexstotsky Jan 15, 2024
e0ede42
Cleanup
alexstotsky Jan 15, 2024
2049b89
Move maintenance modal related stuff to ui redux handlers for consist…
alexstotsky Jan 16, 2024
2c7e745
Update imports and cleanup
alexstotsky Jan 16, 2024
f9b06ed
Update ui selectors default export
alexstotsky Jan 16, 2024
e3311d4
Bump version up to 2.36.0
ZIMkaRU Jan 19, 2024
962d879
Login when otp length is 6
krm35 Jan 21, 2024
b8de71d
Add initial sync info keys/descriptions
alexstotsky Jan 10, 2024
b41c827
Update sync constants
alexstotsky Jan 12, 2024
b413fde
Add showInitSyncPopup action
alexstotsky Jan 12, 2024
202cc09
Actualize sync reducers and initial entries
alexstotsky Jan 12, 2024
8a0e65d
Implement getIsInitSyncPopupOpen selector
alexstotsky Jan 12, 2024
09a7cca
Actualize sync mode mapped props
alexstotsky Jan 12, 2024
538f9e8
Update prop-types
alexstotsky Jan 12, 2024
8a70edb
Improve headers row elements positioning
alexstotsky Jan 16, 2024
b6d9d5e
[wip]Initial sync info popup
alexstotsky Jan 16, 2024
5727c1b
Update popover classes
alexstotsky Jan 16, 2024
75a3360
Add sync info popover styling
alexstotsky Jan 16, 2024
d20be5a
Improve popover arrow styling
alexstotsky Jan 16, 2024
3944e4b
Actualize sync popover content
alexstotsky Jan 16, 2024
244aabc
Add popup close button
alexstotsky Jan 16, 2024
efdbe97
Adjust popup close btn styling
alexstotsky Jan 16, 2024
ad6fd89
Update sync mode container
alexstotsky Jan 16, 2024
4a5272d
Implement sync popup closing, update prop-types
alexstotsky Jan 16, 2024
1c5ae76
Improve popover configuration
alexstotsky Jan 16, 2024
e327ba2
Fix popover still displaying when sync btn is hidden
alexstotsky Jan 17, 2024
5e5b5ee
Implement optional sync progress representation
alexstotsky Jan 17, 2024
50db32e
lint fix
alexstotsky Jan 17, 2024
5960f46
Update sync sagas and popup config
alexstotsky Jan 17, 2024
29a3763
Implement displaying ifo popup on initial sync
alexstotsky Jan 17, 2024
f0a3e4b
Improve sync popup state handling
alexstotsky Jan 17, 2024
704aefd
Update sync sagas
alexstotsky Jan 17, 2024
e1dbe8e
[wip]Check progress values changing
alexstotsky Jan 17, 2024
da40676
Implement long sync checking flow
alexstotsky Jan 17, 2024
aa00e4d
Implement info chnaging for long sync and fix progress displaying
alexstotsky Jan 17, 2024
24e24e7
Improve long sync state handling
alexstotsky Jan 17, 2024
6e0d6ed
Lint fixes and cleanup
alexstotsky Jan 17, 2024
d67eb3f
Implement long sync status redux handling flow
alexstotsky Jan 18, 2024
a38e774
Actualize sync mode mapped props and methods
alexstotsky Jan 18, 2024
11c9da7
Rework long sync state handling flow, update prop-types
alexstotsky Jan 18, 2024
9362000
Implement long sync state handling flow in sagas
alexstotsky Jan 18, 2024
90a4694
Revert "Implement long sync state handling flow in sagas"
alexstotsky Jan 18, 2024
9c953d6
Improve long sync state handling
alexstotsky Jan 18, 2024
0c92886
Memoize sync icon getter
alexstotsky Jan 18, 2024
c4aaeb6
Set sync progress checking timeout to 30 sec
alexstotsky Jan 18, 2024
68a2c60
Cleanup
alexstotsky Jan 19, 2024
32969cb
Actualize ib-js-util-base version
alexstotsky Jan 22, 2024
ba73ebd
Replace lodash isObject usage
alexstotsky Jan 22, 2024
70d2b8b
Improve info popup handling flow for long init sync
alexstotsky Jan 24, 2024
5cd868c
Merge pull request #756 from alexstotsky/inform-about-maintenance
ezewer Jan 26, 2024
bf2fe9c
Add bfxuilib to the reports dependencies
alexstotsky Jan 23, 2024
4d86480
Implement loadAnalyticsIfCookiesAccepted for web mode
alexstotsky Jan 23, 2024
6d3d14e
Implement reusable gtm event tacker
alexstotsky Jan 23, 2024
bf334e7
Add initGoogleTag description for web/app cases
alexstotsky Jan 23, 2024
05f3f37
Optimize framework mode check
alexstotsky Jan 24, 2024
652dac6
Implement navigation sub-sections tracking
alexstotsky Jan 24, 2024
ed05532
Implement nav-switcher tabs tracking
alexstotsky Jan 24, 2024
4575008
Implement sections switcher tabs tracking
alexstotsky Jan 24, 2024
a705d4e
Implement nav menus event tracking
alexstotsky Jan 24, 2024
2df6f74
Update bfxuilib to the latest
alexstotsky Jan 25, 2024
77f8780
Actualize google tag initialization flow
alexstotsky Jan 25, 2024
7fd820e
Implement auth event tracking
alexstotsky Jan 25, 2024
a3adc62
Add sign-up events tracking
alexstotsky Jan 25, 2024
6740102
Add sign-in events tracking
alexstotsky Jan 25, 2024
6fa5ecc
Implement password recovery events tracking
alexstotsky Jan 25, 2024
2067bd6
Add acc menu event tracking
alexstotsky Jan 25, 2024
2bda25b
Update sign-in events tracking
alexstotsky Jan 25, 2024
5986664
Add sub-accs event tracking
alexstotsky Jan 25, 2024
9c23674
Update acc menu event tarcking, unify dialogs toggling
alexstotsky Jan 25, 2024
f177b60
Add sync mode events tracking
alexstotsky Jan 25, 2024
dd8a4a9
Implements query mode events tracking
alexstotsky Jan 25, 2024
738abb6
Add hamburger menu event tracking
alexstotsky Jan 25, 2024
e439559
Add logout event tracking
alexstotsky Jan 25, 2024
fb6d48f
Add export navigation tracking
alexstotsky Jan 25, 2024
a9e97dd
Update tov nav event tracking
alexstotsky Jan 25, 2024
c7a8e02
Add pref btns events tracking
alexstotsky Jan 25, 2024
824d6bc
Add theme switching tracking
alexstotsky Jan 25, 2024
ce04bac
Add timezone picker event tracking
alexstotsky Jan 25, 2024
9c0709c
Implement date format event tracking
alexstotsky Jan 25, 2024
d4e3b94
Update preferences events tracking
alexstotsky Jan 25, 2024
0407401
Add export menu btns tracking
alexstotsky Jan 25, 2024
90a4147
Add error dialog btns tracking
alexstotsky Jan 25, 2024
86ba901
Add export success btn tracking
alexstotsky Jan 25, 2024
7c09bcd
Add date range event tracking
alexstotsky Jan 25, 2024
2efe903
Add time frame btns tracking
alexstotsky Jan 25, 2024
d20351b
Add filter btn event tracking
alexstotsky Jan 25, 2024
37aee19
Update app summary event tracking
alexstotsky Jan 25, 2024
f6f01cd
Implement summary by asset filter evts tracking
alexstotsky Jan 25, 2024
f46db5f
Add query btn tracking
alexstotsky Jan 25, 2024
6df7a39
Implement select btn click tracking
alexstotsky Jan 25, 2024
daab3b8
Cleanup
alexstotsky Jan 25, 2024
fb05791
Update date format selector
alexstotsky Jan 25, 2024
08ceb13
Add lang selector tracking
alexstotsky Jan 25, 2024
f343f09
Add symbol select click tracking
alexstotsky Jan 25, 2024
eaf0e07
Add date input events, update report select type
alexstotsky Jan 25, 2024
d29a840
Update multy-select prop-types
alexstotsky Jan 25, 2024
ee7a122
Add clear symbols click tracking
alexstotsky Jan 25, 2024
89f8b5b
Add category filter type
alexstotsky Jan 25, 2024
2d4113a
Add cols filter btns tracking
alexstotsky Jan 25, 2024
c2fd52c
Add colums select btns tracking
alexstotsky Jan 25, 2024
d2c8e4f
Add go to btns events tracking
alexstotsky Jan 25, 2024
eb2d92d
Update columns filters btns tracking
alexstotsky Jan 25, 2024
ade0b26
Add sync pref btns tracking
alexstotsky Jan 25, 2024
05150f2
Update balance selector type
alexstotsky Jan 25, 2024
2e50042
Add sync pref btns tracking
alexstotsky Jan 25, 2024
08a674f
Update select type
alexstotsky Jan 25, 2024
01fe8a4
Add extra info dialog btn event tracking
alexstotsky Jan 25, 2024
919f440
Add sync symbol pref btns events tracking
alexstotsky Jan 25, 2024
f24da9a
Add derivatives sync pref btns events tracking
alexstotsky Jan 25, 2024
9af0085
Cleanup
alexstotsky Jan 25, 2024
3a7142a
Cleanup
alexstotsky Jan 25, 2024
4032354
Actualize dependencies
alexstotsky Jan 26, 2024
595c597
Minor tweak
alexstotsky Jan 26, 2024
817ded3
Merge pull request #760 from alexstotsky/improve-sync-info
ezewer Jan 26, 2024
6a5478f
Merge pull request #758 from krm35/feat/autoLoginOtp
ezewer Jan 26, 2024
2a8c09a
Merge pull request #761 from alexstotsky/replace-is-object
ezewer Jan 26, 2024
bc4dc4e
Merge pull request #757 from ZIMkaRU/feature/release-version
ezewer Jan 26, 2024
068f6f1
Lint fix
alexstotsky Jan 26, 2024
0d3e3f4
Lint fix
alexstotsky Jan 26, 2024
3977bb2
Merge pull request #763 from alexstotsky/lint-fix
ezewer Jan 26, 2024
a411c43
Add goggleTag utils
alexstotsky Jan 29, 2024
9ae7fbf
Add browser loadScript util
alexstotsky Jan 29, 2024
052158e
Add getBfxEnvName helper
alexstotsky Jan 29, 2024
e61915e
Add logger util
alexstotsky Jan 29, 2024
8fa5ce7
Add loggerLevels platform var
alexstotsky Jan 29, 2024
df6f091
Update goggleTag import
alexstotsky Jan 29, 2024
e1e9029
Add cookieBanner
alexstotsky Jan 29, 2024
2738274
Add js-cookie lib
alexstotsky Jan 29, 2024
1b648f4
Update platform vars
alexstotsky Jan 29, 2024
73933ad
Update browser utils
alexstotsky Jan 29, 2024
a3ba471
Add cookies constants
alexstotsky Jan 29, 2024
c0744d1
Add country codes
alexstotsky Jan 29, 2024
3930695
Add axios required for api utils
alexstotsky Jan 29, 2024
01621b1
Add api utils
alexstotsky Jan 29, 2024
9275e5b
Update platform vars
alexstotsky Jan 29, 2024
313b626
Actualize imports
alexstotsky Jan 29, 2024
461c810
Update canUseAnalyticalCookies import
alexstotsky Jan 29, 2024
3304999
Remove bfxuilib
alexstotsky Jan 29, 2024
ce7cfd8
Actualize version
alexstotsky Jan 29, 2024
c61cdb9
Merge pull request #762 from alexstotsky/add-gtm-tracking
ezewer Jan 30, 2024
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
6,568 changes: 2,530 additions & 4,038 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bfx-report-ui",
"version": "2.35.0",
"version": "2.36.0",
"description": "Report page to overview the user actions in Bitfinex and download related csv files",
"repository": {
"type": "git",
Expand All @@ -23,13 +23,15 @@
"@blueprintjs/select": "^3.8.0",
"@blueprintjs/table": "3.5.0",
"@blueprintjs/timezone": "3.10.1",
"axios": "1.6.7",
"classnames": "2.2.6",
"connected-react-router": "6.9.2",
"flexboxgrid2": "7.2.1",
"history": "^4.9.0",
"i18next": "15.0.7",
"i18next-browser-languagedetector": "3.0.1",
"i18next-http-backend": "1.4.0",
"js-cookie": "2.2.1",
"lightweight-charts": "^1.2.1",
"lodash": "4.17.21",
"memoize-one": "^5.0.2",
Expand Down
18 changes: 17 additions & 1 deletion public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@
"logins": {
"title": "Logins"
},
"maintenance": {
"title": "Maintenance Notice",
"message_1": "The platform is currently in maintenance mode.",
"message_2": "Please check the ",
"message_3": " for updates.",
"message_4": "We will be back soon."
},
"movements": {
"title": "Movements",
"moreDetails": "More Details"
Expand Down Expand Up @@ -649,7 +656,12 @@
"volume": "Volume",
"total": "Total",
"trading_fees": "Trading Fees",
"fund_earnings": "Funding Earnings"
"fund_earnings": "Funding Earnings",
"filter": {
"title": "Filter",
"min_balance_switch": "Minimum Balance",
"min_balance_input": "Set a minimum balance for assets to show up in the table."
}
}
},
"symbols": {
Expand Down Expand Up @@ -679,6 +691,10 @@
"message": {
"canceled": "Canceled old Sync Watcher"
},
"init-sync-info": {
"main": "Welcome to the Bitfinex Reports App. Your trading history is currently synchronizing, please wait until it's finished in order to view your reports.",
"additional": "Syncing is still in progress, this might take several minutes. Keep this window open until it's finished in case you have a large history."
},
"estimated_time": {
"started_at": "Sync started at: ",
"spent_time": "Spent time: ",
Expand Down
26 changes: 18 additions & 8 deletions src/components/AppSummary/AppSummary.byAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@ import { fetchData, refresh } from 'state/summaryByAsset/actions'
import {
getPageLoading,
getDataReceived,
getUseMinBalance,
getMinimumBalance,
getSummaryByAssetTotal,
getSummaryByAssetEntries,
} from 'state/summaryByAsset/selectors'
import { getTimezone } from 'state/base/selectors'
import { getIsSyncRequired } from 'state/sync/selectors'
import { getTimeRange, getTimeFrame } from 'state/timeRange/selectors'

import SummaryFilters from './AppSummary.filters'
import { getAssetColumns } from './AppSummary.columns'
import { prepareSummaryByAssetData } from './AppSummary.helpers'

Expand All @@ -32,6 +35,8 @@ const AppSummaryByAsset = () => {
const entries = useSelector(getSummaryByAssetEntries)
const isSyncRequired = useSelector(getIsSyncRequired)
const { start, end } = useSelector(getTimeFrame)
const minimumBalance = useSelector(getMinimumBalance)
const useMinimumBalance = useSelector(getUseMinBalance)

useEffect(() => {
if (!dataReceived && !pageLoading && !isSyncRequired) {
Expand All @@ -44,8 +49,8 @@ const AppSummaryByAsset = () => {
}, [timeRange])

const preparedData = useMemo(
() => prepareSummaryByAssetData(entries, total, t),
[entries, total, t],
() => prepareSummaryByAssetData(entries, total, t, minimumBalance, useMinimumBalance),
[entries, total, t, minimumBalance, useMinimumBalance],
)

const columns = useMemo(
Expand All @@ -71,12 +76,17 @@ const AppSummaryByAsset = () => {

return (
<div className='app-summary-item full-width-item'>
<div className='app-summary-item-title'>
{t('summary.by_asset.title')}
</div>
<div className='app-summary-item-sub-title'>
{t('summary.by_asset.sub_title')}
{`${formatDate(start, timezone)} - ${formatDate(end, timezone)}`}
<div className='app-summary-item-title--row'>
<div>
<div className='app-summary-item-title'>
{t('summary.by_asset.title')}
</div>
<div className='app-summary-item-sub-title'>
{t('summary.by_asset.sub_title')}
{`${formatDate(start, timezone)} - ${formatDate(end, timezone)}`}
</div>
</div>
<SummaryFilters />
</div>
{showContent}
</div>
Expand Down
102 changes: 102 additions & 0 deletions src/components/AppSummary/AppSummary.filters.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useDispatch, useSelector } from 'react-redux'
import classNames from 'classnames'
import {
Switch,
Popover,
Position,
Alignment,
} from '@blueprintjs/core'

import Icon from 'icons'
import { tracker } from 'utils/trackers'
import InputKey from 'components/Auth/InputKey'
import { getMinimumBalance, getUseMinBalance } from 'state/summaryByAsset/selectors'
import { setMinimumBalance, toggleUseMinimumBalance } from 'state/summaryByAsset/actions'

const SummaryFilters = () => {
const { t } = useTranslation()
const dispatch = useDispatch()
const minimumBalance = useSelector(getMinimumBalance)
const useMinimumBalance = useSelector(getUseMinBalance)
const [isOpen, setIsOpen] = useState(false)
const [balanceValue, setBalanceValue] = useState(minimumBalance)

const togglePopover = (isPopoverOpen) => {
tracker.trackEvent('Filter')
setIsOpen(isPopoverOpen)
}

const onChange = (event) => {
const { value } = event.target
setBalanceValue(value)
dispatch(setMinimumBalance(value))
}

const toggleinimumBalance = () => {
tracker.trackEvent('Minimum Balance')
dispatch(toggleUseMinimumBalance())
}

const classes = classNames('summary-filters--menu', {
'summary-filters--menu-open': isOpen,
})

const switchClasses = classNames('switch-btn', {
active: useMinimumBalance,
})

return (
<div className={classes}>
<Popover
minimal
autoFocus={false}
usePortal={false}
position={Position.BOTTOM_RIGHT}
onOpening={() => togglePopover(true)}
onClosing={() => togglePopover(false)}
content={(
<div className='summary-filters--menu-content'>
<div className='switch-row'>
<div className='switch-title'>
{t('summary.by_asset.filter.min_balance_switch')}
</div>
<Switch
large
className={switchClasses}
checked={useMinimumBalance}
alignIndicator={Alignment.RIGHT}
onChange={toggleinimumBalance}
/>
</div>
<div className='balance-input-label'>
{t('summary.by_asset.filter.min_balance_input')}
</div>
<div className='balance-input'>
<InputKey
type='number'
name='minimumBalance'
value={balanceValue}
onChange={onChange}
disabled={!useMinimumBalance}
/>
<span className='balance-input-currency'>
USD
</span>
</div>
</div>
)}
targetTagName='div'
popoverClassName='summary-filters--menu-popover'
>
<div className='summary-filters--button'>
<Icon.FILTER_SUMMARY />
<span>{t('summary.by_asset.filter.title')}</span>
</div>
</Popover>
</div>
)
}

export default SummaryFilters
11 changes: 8 additions & 3 deletions src/components/AppSummary/AppSummary.helpers.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import React from 'react'
import { fixedFloat, formatThousands } from 'ui/utils'

export const prepareSummaryByAssetData = (entries, total, t) => (
[...entries, { currency: t('summary.by_asset.total'), ...total }]
)
export const prepareSummaryByAssetData = (entries, total, t, minimumBalance, useMinimumBalance) => {
const mergedEntries = [...entries, { currency: t('summary.by_asset.total'), ...total }]
if (useMinimumBalance) {
return mergedEntries.filter(entry => fixedFloat(entry?.balanceUsd, 2) >= minimumBalance)
}
return mergedEntries
}


export const prepareNumericValue = (value) => {
let val = +fixedFloat(value, 2)
Expand Down
Loading