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

(improvement) Dynamic date range support for summary by asset #741

Merged
merged 5 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -638,7 +638,6 @@
},
"by_asset":{
"title": "Summary by Asset",
"sub_title": "For the last 30 days",
"currency": "Currency",
"amount": "Amount",
"balance": "Balance",
Expand Down
11 changes: 7 additions & 4 deletions src/components/AppSummary/AppSummary.byAsset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import { isEmpty } from '@bitfinex/lib-js-util-base'
import NoData from 'ui/NoData'
import Loading from 'ui/Loading'
import DataTable from 'ui/DataTable'
import { fetchData } from 'state/summaryByAsset/actions'
import { fetchData, refresh } from 'state/summaryByAsset/actions'
import {
getPageLoading,
getDataReceived,
getSummaryByAssetTotal,
getSummaryByAssetEntries,
} from 'state/summaryByAsset/selectors'
import { getTimeRange } from 'state/timeRange/selectors'
import { getIsSyncRequired } from 'state/sync/selectors'

import { getAssetColumns } from './AppSummary.columns'
Expand All @@ -21,6 +22,7 @@ import { prepareSummaryByAssetData } from './AppSummary.helpers'
const AppSummaryByAsset = () => {
const { t } = useTranslation()
const dispatch = useDispatch()
const timeRange = useSelector(getTimeRange)
const pageLoading = useSelector(getPageLoading)
const dataReceived = useSelector(getDataReceived)
const total = useSelector(getSummaryByAssetTotal)
Expand All @@ -33,6 +35,10 @@ const AppSummaryByAsset = () => {
}
}, [dataReceived, pageLoading, isSyncRequired])

useEffect(() => {
dispatch(refresh())
}, [timeRange])

const preparedData = useMemo(
() => prepareSummaryByAssetData(entries, total, t),
[entries, total, t],
Expand Down Expand Up @@ -64,9 +70,6 @@ const AppSummaryByAsset = () => {
<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')}
</div>
{showContent}
</div>
)
Expand Down
6 changes: 3 additions & 3 deletions src/components/AppSummary/_AppSummary.scss
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
.full-width-item {
width: 100%;
max-width: 100%;
min-height: 320px;
min-height: 300px;

.bp3-table-container {
box-shadow: none;
Expand Down Expand Up @@ -186,7 +186,7 @@

.loading-container {
display: flex;
min-height: 320px;
min-height: 300px;
max-width: 1000px;

.loading {
Expand All @@ -196,7 +196,7 @@

.no-data {
max-width: 1000px;
min-height: 320px;
min-height: 300px;

&-wrapper {
margin: 150px auto;
Expand Down
7 changes: 5 additions & 2 deletions src/state/summaryByAsset/saga.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ import {
import { makeFetchCall } from 'state/utils'
import { updateErrorStatus } from 'state/status/actions'
import { getIsSyncRequired } from 'state/sync/selectors'
import { getTimeFrame } from 'state/timeRange/selectors'

import types from './constants'
import actions from './actions'

export const getReqSummaryByAsset = () => makeFetchCall('getSummaryByAsset')
export const getReqSummaryByAsset = (params) => makeFetchCall('getSummaryByAsset', params)

export function* fetchSummaryByAsset() {
try {
const { result = {}, error } = yield call(getReqSummaryByAsset)
const { start, end } = yield select(getTimeFrame)
const params = { start, end }
const { result = {}, error } = yield call(getReqSummaryByAsset, params)
yield put(actions.updateData(result))

if (error) {
Expand Down